2014-12-30 178 views
0

我有一個更新面板與一個依賴於情侶的下拉列表。點擊提交按鈕時,面板刷新並重置下拉菜單。用戶參數丟失。有沒有辦法添加代碼來阻止更新面板刷新,我可以將其包含在我的按鈕單擊事件中?如何停止更新面板刷新按鈕單擊?

更新面板:

<asp:ScriptManager ID="ScriptManager1" runat="server" > 
        </asp:ScriptManager> 
        <asp:UpdatePanel ID="UpdatePanel2" runat="server" ChildrenAsTriggers="True"  UpdateMode="Conditional"> 
         <ContentTemplate> 
          <li class="small_link"> .......... 
<li class="small_link"> 
            <div class="li_div"> 
             <asp:Button ID="btnInventoryRpt" runat="server" Text="Load Report" OnClick="btnInventoryRpt_Click" 
             CausesValidation="false" UseSubmitBehavior="False" /> 
            </div> 
           </li> 
          </ContentTemplate>    
         </asp:UpdatePanel> 

按鈕單擊事件:

protected void btnInventoryRpt_Click(object sender, EventArgs e) 
    { 

      load_inventory_report(); 

    } 
+0

你應該把'的UpdatePanel的'Button'出方' – Avijit

+0

[Microsoft - Examples](http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel(v = vs.110).aspx)這裏有幾個Asynchronus回發下拉示例列表 –

+0

Avijit - 當我將按鈕放在更新面板旁邊時,它仍然刷新更新面板。 – briskovich

回答

0

這聽起來對我說,你要綁定在頁面加載事件的dropdownlists,但你忘了網頁提交。

protected void Page_Load(object sender, EventArgs e) 
    { 
     if (!Page.IsPostBack) 
     {     
      //Bind your drowdown list here 
     } 
    } 

但可以使用更多的代碼從你確定。

+0

我試過這個,它可以防止我選擇的索引更改事件不會觸發int更新面板。 – briskovich

0

在你的asp.net頁面刪除您的UpdatePanel標籤ChildreAsTrigger屬性。你只需要的UpdateMode =「有條件」給力更新

<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional" /> 

在您的按鈕單擊事件,那麼你可以強制更新

protected void btnInventoryRpt_Click(object sender, EventArgs e) 
{ 
    load_inventory_report(); 
    UpdatePanel2.Update(); 
} 
相關問題