asp.net按钮点击甚至无法正常工作

时间:2015-02-16 10:22:13

标签: asp.net

按钮单击事件无法在asp.net c#页面中工作。 asp.net验证以此形式使用。

 <div class="TabbedPanelsContentGroup1">
                <div style="border-top: 1px #CCCCCC dotted; text-align: right; padding: 5px 5px 0px 0px; color: #ff5400;">
                    Fields marked * are mandatory</div>
                <asp:ValidationSummary ID="ValidationSummary2" runat="server" ShowMessageBox="true" ShowSummary="False" ValidationGroup="mo" />
                <div alin="centre">
                    <div class="form-field1 pB10 pT20 " style="width: 40%;">
                        <label>
                            <span style="text-align: left;">Select</span>
                            <asp:RadioButtonList ID="rdlUserType1" runat="server" RepeatDirection="Vertical" >
                                <asp:ListItem Value="Deal" Selected="True">&nbsp;&nbsp;Dealers</asp:ListItem>
                                <asp:ListItem Value="Dist">&nbsp;&nbsp;Distributors</asp:ListItem>
                                <asp:ListItem Value="Supp">&nbsp;&nbsp;Suppliers</asp:ListItem>
                            </asp:RadioButtonList>
                        </label>
                    </div>
                    <div class="form-field1 pB10 pT20" style="float: left; width: 40%;">
                        <label>
                            <span style="text-align: left;">Select Country </span>
                            <asp:RadioButtonList ID="rdlSelectCountry1" runat="server" RepeatDirection="Vertical">
                                <asp:ListItem Value="in" Selected="True">&nbsp;&nbsp;INDIA</asp:ListItem>
                                <asp:ListItem Value="ov">&nbsp;&nbsp;OVERSEAS</asp:ListItem>
                            </asp:RadioButtonList>
                        </label>
                    </div>
                </div>
                <div class="form-field1 pT10" style="margin-left: -20px; padding-bottom: 10px; clear: both;">
                    <label>
                        <span>Title*</span>
                        <asp:DropDownList ID="ddlSelect1" runat="server" CssClass="form-bg1" Style="width: 170px;">
                            <asp:ListItem Selected="True" Value="SELECT">SELECT</asp:ListItem>
                            <asp:ListItem>Mr.</asp:ListItem>
                            <asp:ListItem>Mrs.</asp:ListItem>
                            <asp:ListItem>Ms.</asp:ListItem>
                            <asp:ListItem>Dr.</asp:ListItem>
                        </asp:DropDownList>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" InitialValue="SELECT" ValidationGroup="mo" ControlToValidate="ddlSelect1" Display="Dynamic" Style="width: 10px;" ErrorMessage="Please enter Title">*</asp:RequiredFieldValidator>
                    </label>
                </div>
                <div class="form-field1" style="margin-left: -20px; padding-bottom: 10px; clear: both;">
                    <label>
                        <span>First Name*</span>
                        <asp:TextBox ID="txtFirstName1" CssClass="form-bg1" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server" ValidationGroup="mo" ControlToValidate="txtFirstName1" Display="Dynamic" Style="width: 10px;" ErrorMessage="Please enter First Name">*
                        </asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator4" runat="server" ValidationGroup="mo" ErrorMessage="Please enter valid First Name" ControlToValidate="txtFirstName1" Display="Dynamic" Style="width: 10px;" ValidationExpression="^[a-zA-Z]+$">*</asp:RegularExpressionValidator>
                    </label>
                </div>
                <div class="form-field1" style="margin-left: -20px; padding-bottom: 10px;">
                    <label>
                        <span>Last Name*</span>
                        <asp:TextBox ID="txtLastName1" CssClass="form-bg1" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator15" runat="server" ControlToValidate="txtLastName1" ValidationGroup="mo" Display="Dynamic" Style="width: 10px;" ErrorMessage="Please enter Last Name">*
                        </asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator5" runat="server" ErrorMessage="Please enter valid Last Name" ValidationGroup="mo" ControlToValidate="txtLastName1" Display="Dynamic" Style="width: 10px;" ValidationExpression="^[a-zA-Z]+$">*</asp:RegularExpressionValidator>
                    </label>
                </div>
                <div style="clear: both;">
                </div>
                <div class="form-field1" style="margin-left: -20px; padding-bottom: 10px;">
                    <label>
                        <span>Company Name*</span>
                        <asp:TextBox ID="txtCompany1" CssClass="form-bg1" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator16" runat="server" ValidationGroup="mo" ControlToValidate="txtCompany1" Display="Dynamic" Style="width: 10px;" ErrorMessage="Please enter Company Name">* </asp:RequiredFieldValidator>
                    </label>
                </div>
                <div class="form-field1" style="margin-left: -20px; padding-bottom: 10px;">
                    <label>
                        <span>Current Business*</span>
                        <asp:TextBox ID="txtCurrentBusiness1" CssClass="form-bg1" Columns="40" Rows="4" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator17" runat="server" ControlToValidate="txtCurrentBusiness1" ValidationGroup="mo" Display="Dynamic" Style="width: 10px;" ErrorMessage="Please enter Current Business">*
                        </asp:RequiredFieldValidator>
                    </label>
                </div>
                <div style="clear: both;">
                </div>
                <div class="form-field1" style="margin-left: -20px; padding-bottom: 10px;">
                    <label>
                        <span>Email Address*</span>
                        <asp:TextBox ID="txtEmail1" CssClass="form-bg1" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator18" runat="server" ControlToValidate="txtEmail1" ValidationGroup="mo" Display="Dynamic" Style="width: 10px;" ErrorMessage="Please enter Email Address">*
                        </asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator6" runat="server" Style="width: 10px;" ValidationGroup="mo" ErrorMessage="Please enter Valid Email" ControlToValidate="txtEmail1" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">*</asp:RegularExpressionValidator>
                    </label>
                </div>
                <div class="form-field1" style="margin-left: -20px; padding-bottom: 10px;">
                    <label>
                        <span>Phone*</span>
                        <asp:TextBox ID="txtPhone1" CssClass="form-bg1" runat="server" onkeypress="return isNumberKey(event)" MaxLength="15"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator19" runat="server" ValidationGroup="mo" ControlToValidate="txtPhone1" Display="Dynamic" Style="width: 10px;" ErrorMessage="Please enter Phone">*
                        </asp:RequiredFieldValidator>
                    </label>
                </div>
                <div style="clear: both;">
                </div>

                <div style="clear: both;">
                </div>
                <div style="border-top: 1px #CCCCCC dotted; text-align: right; padding: 5px 5px 0px 0px; color: #999999; margin-top: 10px;">
                    &nbsp;</div>
                <div style="margin-left: 15%;">
                    <asp:Button ID="btnSubmit11" runat="server" Text="Submit" CssClass="submit-bt2" ValidationGroup="mo" OnClick="btnSubmit11_Click"/>
                    &nbsp;&nbsp;&nbsp;
                    <asp:Button ID="btnReset1" runat="server" Text="Reset" CssClass="submit-bt" OnClick="btnReset1_Click" CausesValidation="false" />
                </div>
            </div>

protected void btnSubmit11_Click(object sender, EventArgs e)
{

  //code

}
protected void btnReset1_Click(object sender, EventArgs e)
{
    //code
}

1 个答案:

答案 0 :(得分:0)

                                   

1)尝试更改您的onclick方法:OnClick =&#34; btnSubmit11_Click&#34;到OnClick =&#34; btnSubmit_Click&#34;。只需删除数字11.对代码隐藏方法也一样。

2)重建你的项目。

3)如果这不起作用,请通过Visual Studio设计视图在页面中拖动一个新按钮,然后双击Button以生成事件处理程序。然后将旧按钮事件(btnSubmit11_Click)中的代码现有代码添加到新代码中。