I have a page that uses a master page, several RequiredFieldValidators, and the Web Toolkit autocomplete extender. The following code only shows the bare minimum of the page:
<%@ Page Language="C#"
AutoEventWireup="true"
CodeFile="Login.aspx.cs"
MasterPageFile="~/master.master"
Inherits="Login" %>
<asp:Content id="Content1"
contentplaceholderid="ContentPlaceHolder1"
runat="server">
<asp:UpdatePanel ID="pnlUpdate" runat="server">
<ContentTemplate>
<div>
<asp:ImageButton class="submitButton"
imageurl="images/button_submit.gif"
id="btnSubmit"
runat="server"
onclick="btnSubmit_ServerClick"/>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Code-behind:
protected void btnSubmit_ServerClick
(object sender, ImageClickEventArgs e)
{
//breakpoint here does not get hit
}
The <form runat="server">
tag is in the master page. The code above does not fire the onclick event. If I get rid of the master page and add a form tag to the page, it works. Is the form tag in the master page not supported, or is this supposed to work somehow?
alt text http://digitalcopy.warnerbros.com/images/mainmenu.gif?provider=00079&disc=03403AAA-1D20-47F2-91FA-5EE632832659
Because putting the PostBackUrl property and onclick event will not work simultaneously. So, check it carefully, put a debugger on Page_Load and on that ImageButton1_Click event. Check whether it is going to Page_Load or not and then to ImageButton1_Click event. Let me know what are the findings and what is the next problem. One more thing.
At runtime, if you look at the HTML source of the page, you will see the special characters are either ignored or replaced with " _ ". So the page is unable to find the correct control, thus the event won't fire.
At runtime, if you look at the HTML source of the page, you will see the special characters are either ignored or replaced with " _ ". So the page is unable to find the correct control, thus the event won't fire. Try changing the name with plain text, the event will fire. Show activity on this post.
With the UpdatePanel the button's click event will be handled via Javascript, so you might grab FireBug or equivalent (depending on browser) and follow through what actually is happening. Is it tripping on the validation and you don't see it?
My solution was to set the ImageButton's CausesValidation to false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With