一直在撕掉我聽到的這一個。讓我看看是否可以解釋:UpdatePanel,JavaScript回發和在SharePoint搜索頁面同時更改查詢字符串
我有一個SharePoint結果頁,其中有一個Search Results Core WebPart。現在,我想在回發頁面時更改查詢字符串中的參數,以便WebPart爲每個參數返回不同的結果,例如查詢字符串將爲interactivemap.aspx?k =國家:羅馬尼亞,這將過濾羅馬尼亞的結果。
第一個問題是我想用JavaScript來做到這一點,所以我呼籲:
document.getElementById('aspnetForm').action = "interactivemap.aspx?k=Country:" + country;
這裏沒有什麼特別,但我需要從JavaScript調用的原因也有此頁面上的閃光小程序從中Javascript調用發起。當進行javascript調用時,頁面需要PostBack,但不能重新加載Flash小程序。
我轉向ASP.Net AJAX爲此,我將搜索結果webpart包裝在更新面板中。現在,如果我使用UpdatePanel中的按鈕來回發UpdatePanel的行爲,並且執行搜索結果webpart的部分呈現不會重新加載Flash小程序。
問題出現是因爲我需要從javscript回發頁面。我稱之爲__doPostBack(),因爲我過去曾經使用過這種方法。它在它自己的工作,但在我__doPostBack()之前第一次調用上述Javascript時失敗(我也嘗試在隱藏按鈕上調用click()),頁面的代碼位於底部。
我認爲這個問題伴隨着scriptmanager在表單發佈操作發生變化時不允許部分呈現。
我的問題是。
A)有沒有其他方法可以在不使用查詢字符串的情況下更改搜索結果webpart參數。
或
B)是否有周圍做一個AJAX回發時改變查詢字符串,並得到一個局部渲染的方式。
<asp:content contentplaceholderid="PlaceHolderFullContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
<SPSWC:pagelevelerror runat="server" id="PageLevelError"/>
<script type="text/javascript">
function update(country) {
//__doPostBack('ContentUpdatePanel', '');
//document.getElementById('aspnetForm').action = "interactivemap.aspx?k=ArticleCountry:" + country;
document.getElementById('ctl00_PlaceHolderFullContent_UpdateButton').click();
}
</script>
<div id="flashFeature">
<object type="application/x-shockwave-flash" data="_layouts/HFT/flashApplets/interactiveMap/interactiveMap/interactiveMapAssets/IMap.swf" width="100%" height="500px" id="flashContent" style="visibility: visible;">
<param name="bgcolor" value="#cccccc"><param name="allowfullscreen" value="true">
<param name="allowscriptaccess" value="always">
<param name="flashvars" value="ASSETS_FOLDER=_layouts/HFT/flashApplets/interactiveMap/interactiveMap/interactiveMapAssets/">
<param name="movie" value="_layouts/HFT/flashApplets/interactiveMap/interactiveMap/interactiveMapAssets/IMap.swf">
<embed src="_layouts/HFT/flashApplets/interactiveMap/interactiveMap/interactiveMapAssets/IMap.swf" width="100%" height="500px"></embed></object>
</div>
<div onclick="update('Romania');">Romania</div>
<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>
</div>
</asp:content>
+1,該語句'一個更好的方法是使用「正確」的AJAX例如與jQuery' :-) – 2010-03-23 22:10:36
呵呵謝謝。仍然有很多人認爲MS UpdatePanel解決方案是合適的AJAX。 – 2010-03-24 01:23:32
如果不嘗試使用SharePoint組件,那將是更好的方法。 SharePoint喜歡更新面板,並試圖與SharePoint做事情的方式鬥爭是一個非常糟糕的主意。 – 2010-03-24 06:10:21