UpdatePanel, JavaScript postback and changing querystring at same time in SharePoint Search Page
Posted
by Lee Dale
on Stack Overflow
See other posts from Stack Overflow
or by Lee Dale
Published on 2010-03-23T22:03:23Z
Indexed on
2010/03/23
22:13 UTC
Read the original article
Hit count: 1222
Hi Guys,
Been tearing my hear out with this one. Let me see if I can explain:
I have a SharePoint results page on which I have a Search Results Core WebPart. Now I want to change the parameter in the querystring when I postback the page so that the WebPart returns different results for each parameter e.g. the querystring will be interactivemap.aspx?k=Country:Romania this will filter the results for Romania.
First issue is I want to do this with javascript so I call:
document.getElementById('aspnetForm').action = "interactivemap.aspx?k=Country:" + country;
Nothing special here but the reason I need to call from Javascript is there is also a flash applet on this page from which the Javascript calls originate. When the javascript calls are made the page needs to PostBack but not reload the flash applet.
I turned to ASP.Net AJAX for this so I wrapped the search results webpart in an update panel. Now if I use a button within the UpdatePanel to postback the UpdatePanel behaves as expected and does a partial render of the search results webpart not reloading the flash applet.
Problem comes because I need postback the page from javscript. I called __doPostBack() as I have used this successully in the past. It works on it's own but fails when I first call the above Javascript before the __doPostBack() (I also tried calling click() on a hidden button) the code for the page is at the bottom.
I think the problem comes with the scriptmanager not allowing a partial render when the form post action has changed.
My questions are.
A) Is there some other way to change the search results webpart parameter without using the querystring.
or
B) Is there a way around changing the querystring when doing an AJAX postback and getting a partial render.
<asp:Content ContentPlaceHolderID="PlaceHolderFullContent" runat="server">
function update(country)
{
//__doPostBack('ContentUpdatePanel', '');
//document.getElementById('aspnetForm').action = "interactivemap.aspx?k=ArticleCountry:" + country;
document.getElementById('ctl00_PlaceHolderFullContent_UpdateButton').click();
}
<div class="firstDataTitle">
<div class="datatabletitleOuterWrapper">
<div class="datatabletitle">
<span>Content</span></div>
</div>
<div class="datatableWrapper">
<div class="dataHolderWrapper">
<div class="datatable">
<div>
<div class="searchMain">
<div class="searchZoneMain">
<asp:UpdatePanel runat="server" id="ContentUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<WebPartPages:webpartzone runat="server" AllowPersonalization="false" title="<%$Resources:sps,LayoutPageZone_BottomZone%>" id="BottomZone" orientation="Vertical" QuickAdd-GroupNames="Search" QuickAdd-ShowListsAndLibraries="false"><ZoneTemplate></ZoneTemplate></WebPartPages:webpartzone>
<asp:Button id="UpdateButton" name="UpdateButton" runat="server" Text="Update"/>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</div>
</div>
</div>
</div>
</div>
© Stack Overflow or respective owner