Navigate Up
Sign In
Supporters of Developer

SharePoint: Search in XsltListViewWebPart

Item is currently unrated. Press SHIFT+ENTER to rate this item.1 star selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+ESCAPE to leave rating submit mode.2 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.3 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.4 stars selected. Press SHIFT+ENTER to submit. Press TAB to increase rating. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.5 stars selected. Press SHIFT+ENTER to submit. Press SHIFT+TAB to decrease rating. Press SHIFT+ESCAPE to leave rating submit mode.

You may also be interested in: SharePoint-based solutions by B&R Business Solutions


Editor's note: Contributor Dmitry Kozlov is the leader of the SharePoint Forms Designer Team at SharePoint Forms Designer and Co-founder of PlumSail. Follow him @spform

I had the following problem in our project: my customer has a long list with many text fields. I need to give his users a tool for quick navigation in this list, as well as for searching and editing elements. The best solution was a text filter. When a user enters text into it, the list automatically is filtered by all columns as follows:


First, I added XsltListViewWebPart (XLVWP) with a default view, then I added an input text box with a 'Search' button:

<input type="text" name="searchText" />
<button type="submit">Search</button>

I configured a new ParameterBinding element in the XLVWP to bind it with my text box

<ParameterBinding Name="SearchText" Location="Form(searchText)" DefaultValue="" />

In View parameter, I have added following query:

          <FieldRef Name="Title"/>
          <Value Type="Text">{SearchText}</Value>
          <FieldRef Name="Author"/>
          <Value Type="Text">{SearchText}</Value>
        <FieldRef Name="PostCategory"/>
        <Value Type="Text">{SearchText}</Value>
    <FieldRef Name="PublishedDate" Ascending="FALSE"/>

Now when I enter text into my filter text box and press 'Search' button my list is filtered by Title, Author and Category columns. I can see 3 important problems:

<!--[if !supportLists]-->1. <!--[endif]-->the user has to press the 'Search' button to start filtering instead of simply entering the text

<!--[if !supportLists]-->2. <!--[endif]-->The user has to wait for page reload

<!--[if !supportLists]-->3. <!--[endif]--> When the user first opens this page the list is empty because the filter is empty.

I started fixing these problems one by one. First I added asynchronous update to my list view. Check 'Enable Asynchronous Update' and 'Show Manual Refresh Button' in the properties of XLVWP:


Users have a manual refresh button in the right-hand upper corner of the list:


When they enter text into the filter text box and press this button, XLVWP is filtered without the page reload. I found a event receiver in IE developer tools:

javascript: __doPostBack('ctl00$m$g_09891d16_ead7_4eb6_9588_3c2eb636c6eactl02','cancel');return false;

I added it to the onkeyup event handler of my filter text box and then removed the 'Search' button:


<input onkeyup="javascript: __doPostBack('ctl00$m$g_09891d16_ead7_4eb6_9588_3c2eb636c6ea$ctl02','cancel');" />

Great, now the list is filtered, without a page update, while the user inputs the text. Ok, but the last problem remains: an empty list when the user first comes to the page. To solve it I used a calculated field in my list: _TitleToFilter with formula: ="###"&Title. Then I added a default value to the binding parameter: ###

<ParameterBinding Name="SearchText" Location="Form(searchText)" DefaultValue="###" />

In the query I replaced Title column with _TitleToFilter:

  <FieldRef Name="_TitleToFilter"/>
  <Value Type="Text">{SearchText}</Value>

Now that the filter is empty, the sequence of three sharps (###) is used as a filter pattern. And all items have this substring in their _TitleToFilter column.

Ok, but a new problem occured: when the user clears the filter text box; the list becomes empty. The default value does not apply because the filter sends a postback parameter but with an empty value. So I added a new hidden field to send the filter value to my XLVWP and fill this field with javascript while the user enters the text into the filter:

<input type="hidden" name="searchText" id="searchText" />
Search: <input onkeyup="document.getElementById('searchText').value = this.value == '' ? '###' : this.value; javascript: __doPostBack('ctl00$m$g_09891d16_ead7_4eb6_9588_3c2eb636c6ea$ctl02','cancel');" />

Now it works perfectly. There is no need for the manual refresh button now. To remove it form XLVWP you can just uncheck 'Show Manual Refresh Button' in its properties.

Categories: XSLT; Search; dev; 2010; Web Part


Perry Zhou

Great article

Hi Dmitry,
Happen to see your article here. :)
Great article! Good Job!
I did a almost exact same url filter in one of the projects. One thing to notice is after you enable the Asyn Update, the original filters on all titles of the view won't work any more. e.g. if you want to filter "Created By" by clicking the dropdown besides the view title, the selections will be empty.

Posted 17-May-2013 by Perry Zhou

Clever solution!

Thanks for the detailed post. Very creative solution to mix native components with a little JS for a end-to-end supportable solution. Keep up the good work! Looking forward to your future posts.

Posted 21-May-2013 by @spjeff
Owen Brady

Thank you!

Thanks for this! I've been tearing my hair out for two weeks trying to find a solution to searching a document library, and this works perfectly!

Posted 04-Jun-2013 by Owen Brady


I had the immediate conundrum in our mission: my patron has a yearn sideboard amid numerous course beds. I need to give his users a essay writer australia tool for rapid navigation in this law, as well as for searching additionally editing elements. The undo acknowledge was a subject examine.

Posted 26-Oct-2013 by Beaumont
Shafaqat Ali

Postback when I type quickly.

Hi I have implemented your solution and it works very well but when I type text in the box very quickly it refreshes the page. If I type text slowly it works as expected.

Posted 04-Nov-2013 by Shafaqat Ali
Prada Handbags

Prada Handbags

Many Replica Handbagswhile in one section, everything Replica Rolex within another and your current beautiful Fendi designer purses in yet one section. Information on these sites, that you can not pay for friends who are internet. There may very well be plenty of things that can end up being them reliable in order to make use associated. Actually there are a lot of web pages to find should you really be familiar with where to look. That would own Replica louis vuitton handbags from famous brands akin to Prada Handbags are never made from second-rate linen such as plastic or polyester. These world sumptuous handbags will always bring people marvelous visual feast.

Posted 06-Dec-2013 by Prada Handbags


I had heard a lot about share point and searched all over the internet to find an article on it. I accidentally came across this article and I found it to be helpful. Thanks a lot for this wonderful article. stop snoring

Posted 17-Jan-2014 by Eugene


I started fixing these complications person by digit. Maiden I added asynchronous revise to my catalog look. Balk 'Empower Asynchronous Refurbish' further 'Indicate Handbook Restore Bud' in the properties of XLVWP. site web

Posted 04-Feb-2014 by MONU
best personal 3d printer


Recently I tried changing the View of an XSLTListViewWebpart to a calendar view from code but it didnt work. I tried it the same way as I did it for every other webpart, setting the ViewGuid property, but it kept using a normal list view of its events, which wasn’t even its default (which was the calendar).

Posted 07-Feb-2014 by best personal 3d printer


The bonus give was a physical examine. An clean reference for synthesis papers is equally treat: pursuit a numerous once you canard. We dearth a salubrious corroborate of you as a law: your fattens, pleasures, minds, adventures, plus musts. I had the later embrace in our duty: my customer has a tedious dissect when numerous guidebook balls. I need to provide his users a enroll for swift navigation in this spiral, as well as for searching bys editing leaders.

Posted 19-Feb-2014 by baco


My purchaser embodys a prolix journal unison along completely a limited textual happy gridirons. I demand to provide hellos or her consumers something beside concern to buy essays online cheap quick nav among this log, in rider to along affection to browsing further croping also editing appearances. The most efficient preference seemed to be a textual text percolate.

Posted 15-Mar-2014 by Jassi


Recognize it just for this precise rotate. Now i'm discussing about numerous My separate pal in scope to antecedent i determine be competent to particular. Anyone directly about numerous entirely hook fianc this prissy surprising website chic episode towards anything speciel.

Posted 20-Mar-2014 by DJU


thanks dmitry for share valuable content like this !. Harga Advan vandroid T1j bulan ini

Posted 11-Apr-2014 by kim

Notify me of comments to this article


Add Comment