I have a master page. In the master page I have a UserControl for the footer. In the footer I have a button that is not firing OnClick. During debugging I see the function being called by OnClick, btnSignup_Click, is not getting hit. I can't seem to figure out where the mistake in my code is.
master.master
<%@ Master Language="C#" AutoEventWireup="true" Inherits="master" Codebehind="master.master.cs" %>
<%@ Register TagPrefix="xyz" TagName="Footer" Src="~/controls/footer.ascx" %>
<xyz:Footer ID="Footer" runat="server" />
footer.ascx
<%@ Control Language="C#" AutoEventWireup="true" Inherits="footer" Codebehind="footer.ascx.cs" %>
<div>
<asp:TextBox ID="fName" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidatorfName" ValidationGroup="validationSignup" Display="Static" ControlToValidate="fName" ErrorMessage="First Name required" runat="server"></asp:RequiredFieldValidator>
</div>
<div class="button">
<asp:Button ID="btnSignup" CommandName="Button" runat="server" ValidationGroup="validationSignup" Text="Signup" HeaderText="Please fill in all required fields before continuing." OnClick="btnSignup_Click"/>
</div>
<div class="validationSummary">
<asp:ValidationSummary ID="ValidationSummary" ValidationGroup="validationSignup" runat="server"></asp:ValidationSummary>
</div>
footer.ascx.cs
public partial class templates_site_footer : BaseUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
btnSignup.Click += new EventHandler(btnSignup_Click);
}
protected void btnSignup_Click(object sender, EventArgs e)
{
if (!Page.IsValid)
return;
// code to execute after button is clicked
}
}
Aucun commentaire:
Enregistrer un commentaire