ImageButton in UpdatePanel doesn't PostBack
I created a form in a popup div, that contain an UpdatePanel with ImageButtons in it.
Initially, I used Lin开发者_如何学GokButtons to test but I wanted ImageButtons. The thing is, it works well with LinkButtons and not with ImageButtons (absolutely nothing happens).
Checking the source, I see that the javascript call is a little different :
LinkButton :<a href="javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$cphC$ctrlAdr$AdrMapo$lbAdresseSaisie", "", true, "", "", 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("ctl00$cphC$ctrlAdr$AdrMapo$rpAdressesProposees$ctl00$ibAdresseProposee", "", true, "", "", false, false))" ...>
After checking the doc, I see that the last parameter of WebForm_PostBackOptions
is called clientSubmit
and if it is set to true
a submit is performed.
For the ImageButton this value is set to false
and if I change it to true
manually with Firebug, it works as expected.
But I can't find anywhere a way to change that parameter when the control is drawn. And that's quite annoying.
If I set ImageButton.CausesValidation
, there is no javascript generated and nothing happen when I click on the button.
The UpdatePanel is declared like this :
<asp:UpdatePanel ID="upAdressesProposees" ChildrenAsTriggers="true"
UpdateMode="Conditional" runat="server" Visible="true">
And to be sure I declared a trigger for the ImageButton.
I use UpdateMode="conditional"
because it needs to be updatable programmingly from outside of the UpdatePanel events.
The LinkButton submits correctly in exactly the same situation so I don't know what I did wrong here...
Is there any client side validation being performed that is blocking the postback? Does it do a postback if you remove the UpdatePanel from the page? I would test that so you determine if it is a problem with the UpdatePanel + ImageButton or just the Imagebutton.
精彩评论