簡體   English   中英

UpdatePanel中的ImageButton不回發

[英]ImageButton in UpdatePanel doesn't PostBack

我在彈出div中創建了一個表單,其中包含一個帶有ImageButtons的UpdatePanel。

最初,我使用LinkBut​​tons進行測試,但我需要ImageButtons。 事實是,它與LinkBut​​tons而不與ImageButtons一起很好地工作(絕對沒有任何反應)。

檢查源代碼,我發現javascript調用有點不同:
LinkBut​​ton:

 <a href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$cphC$ctrlAdr$AdrMapo$lbAdresseSaisie&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, true))" id="ctl00_cphC_ctrlAdr_AdrMapo_lbAdresseSaisie">test</a> 

ImageButton:

 <input align="absmiddle" type="image" style="border-width:0px;" onclick="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;ctl00$cphC$ctrlAdr$AdrMapo$rpAdressesProposees$ctl00$ibAdresseProposee&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))" ...> 

檢查文檔后,我看到WebForm_PostBackOptions的最后一個參數稱為clientSubmit ,如果將其設置為true則執行提交。 對於ImageButton,此值設置為false ,如果我使用Firebug手動將其更改為true ,它將按預期工作。 但是在繪制控件時,我找不到任何方法可以更改該參數。 這很煩人。

如果設置ImageButton.CausesValidation ,則不會生成任何JavaScript,並且單擊按鈕時不會發生任何事情。 UpdatePanel的聲明如下:

<asp:UpdatePanel ID="upAdressesProposees" ChildrenAsTriggers="true"
UpdateMode="Conditional" runat="server" Visible="true">

並且確保我聲明了ImageButton的觸發器。 我使用UpdateMode="conditional"因為它需要從UpdatePanel事件外部以編程方式進行更新。

LinkBut​​ton在完全相同的情況下可以正確提交,所以我不知道我在這里做錯了什么...

是否正在執行任何阻止回發的客戶端驗證? 如果從頁面中刪除UpdatePanel,它會回發嗎? 我會測試一下,以便您確定是UpdatePanel + ImageButton還是ImageButton出現問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM