[英]ImageButton in UpdatePanel doesn't PostBack
I created a form in a popup div, that contain an UpdatePanel with ImageButtons in it. 我在弹出div中创建了一个表单,其中包含一个带有ImageButtons的UpdatePanel。
Initially, I used LinkButtons to test but I wanted ImageButtons. 最初,我使用LinkButtons进行测试,但我需要ImageButtons。 The thing is, it works well with LinkButtons and not with ImageButtons (absolutely nothing happens). 事实是,它与LinkButtons而不与ImageButtons一起很好地工作(绝对没有任何反应)。
Checking the source, I see that the javascript call is a little different : 检查源代码,我发现javascript调用有点不同:
LinkButton : 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 : 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. 检查文档后,我看到WebForm_PostBackOptions
的最后一个参数称为clientSubmit
,如果将其设置为true
则执行提交。 For the ImageButton this value is set to false
and if I change it to true
manually with Firebug, it works as expected. 对于ImageButton,此值设置为false
,如果我使用Firebug手动将其更改为true
,它将按预期工作。 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. 如果设置ImageButton.CausesValidation
,则不会生成任何JavaScript,并且单击按钮时不会发生任何事情。 The UpdatePanel is declared like this : UpdatePanel的声明如下:
<asp:UpdatePanel ID="upAdressesProposees" ChildrenAsTriggers="true"
UpdateMode="Conditional" runat="server" Visible="true">
And to be sure I declared a trigger for the ImageButton. 并且确保我声明了ImageButton的触发器。 I use UpdateMode="conditional"
because it needs to be updatable programmingly from outside of the UpdatePanel events. 我使用UpdateMode="conditional"
因为它需要从UpdatePanel事件外部以编程方式进行更新。
The LinkButton submits correctly in exactly the same situation so I don't know what I did wrong here... LinkButton在完全相同的情况下可以正确提交,所以我不知道我在这里做错了什么...
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? 如果从页面中删除UpdatePanel,它会回发吗? I would test that so you determine if it is a problem with the UpdatePanel + ImageButton or just the Imagebutton. 我会测试一下,以便您确定是UpdatePanel + ImageButton还是ImageButton出现问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.