Click here to Skip to main content
15,906,455 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello freinds ,
i am working on a simple submit form .i have applied some validation on the form.But after all validations my form is not submitting (Page is not post backing).I am very confuse.Can you please help me what is happening.Please help me guys.This is my code.


ASP.NET
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">


    <div style="width: 100%;">
        <asp:Panel ID="FirstPanel" runat="Server" Visible="true" DefaultButton="Button1">
            <table width="100%" cellpadding="5px" cellspacing="0" border="0">
          
                <tr>
                    <td style="padding-removed 11px">
                        <table align="center" width="100%" cellpadding="5px" cellspacing="0" class="login_border">
                            <tr>
                                <td class="login_heading">
                                    <table align="center" width="100%" cellpadding="0px" cellspacing="0">
                                        <tr>
                                            <td class="login_border_bottom" height="20px">
                                                Personal Information
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td class="Login_Text1 align_justified">
                                    <table width="100%" cellpadding="0" cellspacing="0">
                                        <tr>
                                            <td>
                                                <table width="%" cellpadding="3px" cellspacing="0">
                                                    <tr>
                                                        <td class="black_11px" style="vertical-align:top">
                                                            First Name</td>
                                                        <td align="left" style="vertical-align:top">
                                                            <asp:TextBox ID="txtFirstName"  Width="220px" runat="server"></asp:TextBox><br />
                                                              <asp:RequiredFieldValidator  ID="reqUserName"
                        runat="server" ControlToValidate="txtFirstName"
            ValidationGroup="RegEditvalidate"    Text="Please enter first name!" Display="Dynamic" />

         <%--   <asp:RegularExpressionValidator ID="regexe" ValidationExpression="[a-zA-Z]{1}[0-9a-zA-Z]{2,}"
                Text="Enter Minimum 3 Numeric/Character/ AlphaNumeric Values must Start with a character value" 
            ValidationGroup="RegEditvalidate"   Display="Dynamic"    ControlToValidate="txtFirstName" runat="server">
            </asp:RegularExpressionValidator>--%>
                           
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="black_11px" style="vertical-align:top">
                                                            Last Name</td>
                                                        <td align="left" style="vertical-align:top">
                                                            <asp:TextBox ID="txtLastName"  Width="220px" runat="server"></asp:TextBox>
                                                            <br />
                                               <asp:RequiredFieldValidator  ID="RequiredFieldValidator5" runat="server" ControlToValidate="txtLastName"
               ValidationGroup="RegEditvalidate"  Text="Please enter last Name!" Display="Dynamic" />
        <%--    <asp:RegularExpressionValidator ID="RegularExpressionValidator1" ValidationExpression="[a-zA-Z]{1}[0-9a-zA-Z]{2,}"
             Display="Dynamic"   Text="Enter Minimum 3 Numeric/Character/ AlphaNumeric Values must Start with a character value" 
            ValidationGroup="RegEditvalidate"     ControlToValidate="txtLastName" runat="server">
            </asp:RegularExpressionValidator>--%>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td class="black_11px" style="vertical-align:top">
                                                            Contact No</td>
                                                        <td align="left" style="vertical-align:top">
                                                            <asp:TextBox ID="txtContactNo"  Width="220px"  MaxLength="15" runat="server"></asp:TextBox>
                                                            <br />
                                                                 <asp:RequiredFieldValidator ID="reqNumber"  runat="server" ControlToValidate="txtContactNo"
              ValidationGroup="RegEditvalidate"  Display="Dynamic"  Text="Please fill number!"  />
       <%--     <asp:RegularExpressionValidator ID="RegularExpressionValidator4" ValidationExpression="^[0-9]{10}" 
               ValidationGroup="RegEditvalidate"  Display="Dynamic"  Text="Enter 10 Digit Number Only" ControlToValidate="txtContactNo" 
                runat="server">
            </asp:RegularExpressionValidator>--%>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td>
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td height="20px">
                                </td>
                            </tr>
                        </table>
                        <br />
                        <br />
                        <table align="center" width="100%" cellpadding="5px" cellspacing="0" class="login_border">
                            <tr>
                                <td class="login_heading">
                                    <table align="center" width="100%" cellpadding="0px" cellspacing="0">
                                        <tr>
                                            <td class="login_border_bottom"  height="20px">
                                                Login Information
                                            </td>
                                        </tr>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td class="Login_Text1 align_justified" width="100%">
                                    <table width="100%" cellpadding="3px" cellspacing="0">
                                        <tr>
                                            <td class="black_11px" width="160px" style="vertical-align:top">
                                                Email Address</td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:Label ID="lblEmailAddress" Width="220px"  runat="server"></asp:Label>
                                 <%--               <br />
                                                  <asp:RequiredFieldValidator ID="reqEmailAddress" runat="server" ControlToValidate="txtEmailAddress"
                Text="Please fill Email ID!" Display="Dynamic" /><br />
            <asp:RegularExpressionValidator runat="server" ID="rexEmailID" ControlToValidate="txtEmailAddress" 
                ValidationExpression="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum|in|co.in)\b"
                Text="Please Enter valid Email Address!" Display="Dynamic" />--%>
                                            </td>
                                        </tr>
                  
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                Password</td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:TextBox ID="txtpassword" runat="server" Width="220px"></asp:TextBox>
                                        <br /> <asp:RequiredFieldValidator ID="RequiredFieldValidator6"  runat="server" ControlToValidate="txtPassword"
             ValidationGroup="RegEditvalidate"    Text="Please Enter Password!" Display="Dynamic" />
         <%--          <asp:RegularExpressionValidator ID="RegularExpressionValidator2" ValidationExpression="[a-zA-Z]{1}[0-9a-zA-Z]{5,}"
             Display="Dynamic"   Text="Enter Minimum 6 Numeric/Character/ AlphaNumeric Values must Start with a character value" 
              ValidationGroup="RegEditvalidate"   ControlToValidate="txtpassword" runat="server">
            </asp:RegularExpressionValidator>--%>

                                            </td>
                                        </tr>
                                
                                    </table>
                                  
                                </td>
                            </tr>
                 
                        </table>
                    </td>
                </tr>
            </table>
        </asp:Panel>
        <asp:Panel ID="SecondPanel" DefaultButton="Button1" runat="Server" >
            <table width="100%" cellpadding="5px" cellspacing="0" border="0">
  
                <tr>
                    <td style="padding-removed 11px">
                        <table align="center" width="100%" cellpadding="5px" cellspacing="0" class="login_border">
                            <tr>
                                <td class="login_heading">
                                    <table align="center" width="100%" cellpadding="0px" cellspacing="0">
                                        <tr>
                                            <td class="login_border_bottom" height="20px">
                                                Other Information
                                            </td></tr>
                                             <tr>
                                            <td height="20px" align="center">
                                               <span style="text-decoration:underline">Primary Address</span> 
                                            </td>
                                        </tr>
                                      
                                    </table>
                                </td>
                            </tr>
                            </table></td></tr>
                            <tr>
                                <td class="Login_Text1 align_justified">
                       
                                    <table align="center" width="100%">
                                        <tr>
                                            <td class="black_11px" style="width: 40%;vertical-align:top">
                                 
                                                Choose Country
                                              
                                            </td>
                                            <td style="padding-removed 10px;vertical-align:top;">
                                       
                                                  <asp:DropDownList ID="ddlCountry"  runat="server" 
                                                  OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged"
                    AutoPostBack="true" Width="305px" CssClass="textfordropdown">
                </asp:DropDownList>
                <br />
                <asp:RequiredFieldValidator ID="reqCountry" runat="server"  ControlToValidate="ddlCountry"
                    Text="Please select Country!" Display="Dynamic"  ValidationGroup="RegEditvalidate" InitialValue="Select Country" />
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                       
                                                Choose State
                                            </td>
                                            <td style="padding-removed 10px;vertical-align:top;">
                                               <asp:UpdatePanel runat="server" ID="upState">
                    <ContentTemplate>
                        <asp:DropDownList ID="ddlState" runat="server"  OnSelectedIndexChanged="ddlState_SelectedIndexChanged"
                            AutoPostBack="true" Enabled="true" Width="305px" CssClass="textfordropdown">
                            <asp:ListItem Text="Select State" Value="0"></asp:ListItem>
                        </asp:DropDownList>
                        <br />
                        <asp:RequiredFieldValidator ID="reqState"  runat="server" ControlToValidate="ddlState"
                            Text="Please select State!" Display="Dynamic"  ValidationGroup="RegEditvalidate" InitialValue="Select State" />
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="ddlCountry"  EventName="SelectedIndexChanged" />
                    </Triggers>
                </asp:UpdatePanel>
                                         </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px">
                            
                                                City
                                            </td>
                                            <td style="padding-removed 10px;vertical-align:top;">
                                            
                                            <table cellpadding="0px" cellspacing="0" width="100%" border="0px" style="text-align: left">
                                                        <tr>
                                                            <td class="black_11px"  style="width:34%">
                                                           <asp:UpdatePanel runat="server" ID="UpdatePanel6">
                    <ContentTemplate>
                        <asp:DropDownList ID="ddlCity" runat="server"  Enabled="true" Width="305px" CssClass="textfordropdown">
                            <asp:ListItem Text="Select City" Value="0"></asp:ListItem>
                        </asp:DropDownList>
                        <br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator2"  runat="server" ControlToValidate="ddlCity"
                            Text="Please select City!" Display="Dynamic"  ValidationGroup="RegEditvalidate" InitialValue="Select City" />
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="ddlState" EventName="SelectedIndexChanged" />
                    </Triggers>
                </asp:UpdatePanel>
                                                            </td>
                                                            <td align="left">
                                                       
                                                   </td>
                                                        </tr>
                                                    </table>
                                                    
                              
                                            </td>
                                        </tr>
                                        <tr>
                                            <td colspan="2" style="padding: 0 0 0 0; border: 0">
                                                <div id="branchDiv" style="visibility: hidden; display: none">
                                                    <table cellpadding="0px" cellspacing="0" width="100%" border="0px" style="text-align: left">
                                                        <tr>
                                                            <td class="black_11px" style="width: 34%;vertical-align:top;">
                                                                City Name
                                                            </td>
                                                            <td align="left" style="vertical-align:top">
                                                                <asp:TextBox ID="txtAddCity"  Width="220px" runat="server"></asp:TextBox>
                                                         <br />          <asp:RequiredFieldValidator  ID="Requiredcity" text="Enter city"
                     Display="Dynamic"  ValidationGroup="RegEditvalidate" ControlToValidate="txtAddCity" runat="server">
                    </asp:RequiredFieldValidator>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </div>
                                            </td>
                                        </tr>
                                         <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                Address 1
                                            </td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:TextBox ID="txtstreetone"  Width="220px" runat="server"></asp:TextBox>
                                                    <br />          <asp:RequiredFieldValidator  ID="RequiredFieldValidator9" text="Enter address 1"
                     Display="Dynamic"  ValidationGroup="RegEditvalidate" ControlToValidate="txtstreetone" runat="server"></asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                Address 2</td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:TextBox ID="txtStreetTwo" Width="220px"  runat="server"></asp:TextBox>
                                                 <br />          <asp:RequiredFieldValidator  ID="RequiredFieldValidator10" text="Enter address 2"
                      Display="Dynamic"  ValidationGroup="RegEditvalidate" ControlToValidate="txtStreetTwo" runat="server"></asp:RequiredFieldValidator>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                Pin Code</td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:TextBox ID="txtAddPinCode"  MaxLength="8" Width="220px" runat="server"></asp:TextBox>
                                                  <br />          <asp:RequiredFieldValidator ID="RequiredFieldValidator11" text="Enter pincode"
                      Display="Dynamic"  ValidationGroup="RegEditvalidate" ControlToValidate="txtAddPinCode" runat="server"></asp:RequiredFieldValidator>
                                               <br />
                                              <%--  <asp:RegularExpressionValidator  ID="RegularExpressionValidator3"
                                             Display="Dynamic"  ValidationGroup="RegEditvalidate"    ValidationExpression="^[0-9]{6,}"
                Text="Enter Number More then 6 Only" ControlToValidate="txtAddPinCode" runat="server"></asp:RegularExpressionValidator>--%>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" colspan="2" >
                                             <asp:Label ID="lblvalidate"  ForeColor="Red" runat="server"
                                             Width="400px"   CssClass="textRed"></asp:Label><br />
                                                Same as Primary Address   
                                                <asp:CheckBox ID="chkPrimaryAddress"  AutoPostBack="true" runat="server" />
                                            </td>
                                        </tr>
                                          <tr>
                                          <td class="login_heading" align="center" colspan="2">
                                                <span style="text-decoration:underline"> Billing Address</span>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                Choose Country
                                            </td>
                                            <td style="padding-removed 10px;vertical-align:top;">
                                                <asp:UpdatePanel runat="server" ID="UpdatePanel2">
                                                    <contenttemplate>
                                                  <asp:DropDownList ID="ddlCountry2" runat="server" OnSelectedIndexChanged="ddlCountry2_SelectedIndexChanged"
                    AutoPostBack="true" Width="305px"  CssClass="textfordropdown">
                </asp:DropDownList>
                <br />
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="ddlCountry2" 
                    Text="Please select Country!" Display="Dynamic"  ValidationGroup="RegEditvalidate" InitialValue="Select Country" />
                                                              </contenttemplate>
                                                    <triggers>
                                                <asp:AsyncPostBackTrigger ControlID="chkPrimaryAddress" EventName="CheckedChanged" />
                                            </triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                Choose State
                                            </td>
                                            <td style="padding-removed 10px;vertical-align:top;">
                                                <asp:UpdatePanel runat="server" ID="UpdatePanel8">
                                                 
                                                                                          
                                             <ContentTemplate>
                        <asp:DropDownList ID="ddlState2" runat="server" OnSelectedIndexChanged="ddlState2_SelectedIndexChanged" 
                            AutoPostBack="true" Enabled="true" Width="305px" CssClass="textfordropdown">
                            <asp:ListItem Text="Select State" Value="0"></asp:ListItem>
                        </asp:DropDownList>
                        <br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="ddlState2" 
                            Text="Please select State!" Display="Dynamic"  ValidationGroup="RegEditvalidate" InitialValue="Select State" />
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="ddlCountry2" EventName="SelectedIndexChanged" />
                    </Triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                City
                                            </td>
                                            <td style="padding-removed 10px;vertical-align:top;">
                                           
                                                                                               <table cellpadding="0px" cellspacing="0" width="100%" border="0px" style="text-align: left">
                                                        <tr>
                                                            <td class="black_11px"  style="width:34%;vertical-align:top;">
                                                           <asp:UpdatePanel runat="server" ID="UpdatePanel7">
                    <ContentTemplate>
                        <asp:DropDownList ID="ddlCity2" runat="server"  Enabled="true" Width="305px" CssClass="textfordropdown">
                            <asp:ListItem Text="Select City" Value="0"></asp:ListItem>
                        </asp:DropDownList>
                        <br />
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator4"  runat="server" ControlToValidate="ddlCity2" 
                            Text="Please select City!" Display="Dynamic"  ValidationGroup="RegEditvalidate" InitialValue="Select City" />
                    </ContentTemplate>
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="ddlState2" EventName="SelectedIndexChanged" />
                    </Triggers>
                </asp:UpdatePanel>
                                                            </td>
                                                            <td align="left" style="vertical-align:top">
                                                                           
                                                            </td>
                                                        </tr>
                                                    </table>
                                          
                                       
                                            </td>
                                        </tr>
                                 
                                        <tr>
                                            <td class="black_11px"  style="vertical-align:top">
                                                Address 1
                                            </td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:UpdatePanel runat="server" ID="UpdatePanel10">
                                                    <contenttemplate>
                                                            <asp:TextBox  ID="txtBillStreetOne" Width="220px" runat="server"></asp:TextBox>
                          <br />  <asp:RequiredFieldValidator ID="req3" Display="Dynamic"  ValidationGroup="RegEditvalidate"  runat="server"  Text="Enter billing address 1"  ControlToValidate="txtBillStreetOne"> 
                                                            </asp:RequiredFieldValidator>
                                                             </contenttemplate>
                                                    <triggers>
                                                <asp:AsyncPostBackTrigger ControlID="chkPrimaryAddress" EventName="CheckedChanged" />
                                            </triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                Address 2</td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:UpdatePanel runat="server" ID="UpdatePanel3">
                                                    <contenttemplate>
                                                            <asp:TextBox ID="txtBillStreetTwo" Width="220px" runat="server"></asp:TextBox>
                                                               <br />  <asp:RequiredFieldValidator  ID="RequiredFieldValidator12" 
                                                                runat="server"  Text="Enter billing address 2" Display="Dynamic"  ValidationGroup="RegEditvalidate" ControlToValidate="txtBillStreetTwo"> 
                                                            </asp:RequiredFieldValidator>
                                                             </contenttemplate>
                                                    <triggers>
                                                <asp:AsyncPostBackTrigger ControlID="chkPrimaryAddress" EventName="CheckedChanged" />
                                            </triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                Pin Code</td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:UpdatePanel runat="server" ID="UpdatePanel4">
                                                    <contenttemplate>
                                                            <asp:TextBox ID="txtBillPinCode"  MaxLength="8" Width="220px" runat="server"></asp:TextBox>
                                                     <br />       <asp:RequiredFieldValidator ID="RequiredFieldValidator13" 
                                                                runat="server"  Text="Enter billing pincode"  Display="Dynamic"  ValidationGroup="RegEditvalidate"  ControlToValidate="txtBillPinCode"> 
                                                            </asp:RequiredFieldValidator>
                                                            <%--  <br />
                                                <asp:RegularExpressionValidator ID="RegularExpressionValidator22" ValidationExpression="^[0-9]{6,}"  Display="Dynamic"  ValidationGroup="RegEditvalidate"
                Text="Enter Number More then 6 Only" ControlToValidate="txtBillPinCode" runat="server"></asp:RegularExpressionValidator>--%>
                                                             </contenttemplate>
                                                    <triggers>
                                                <asp:AsyncPostBackTrigger ControlID="chkPrimaryAddress" EventName="CheckedChanged" />
                                            </triggers>
                                                </asp:UpdatePanel>
                                            </td>
                                        </tr>
                                  <%--      <tr>
                                            <td class="black_11px" style="vertical-align:top">
                                                How did you know about us
                                            </td>
                                            <td align="left" style="vertical-align:top">
                                                <asp:DropDownList ID="ddlHearAbout"  runat="server">
                                                    <asp:ListItem Text="Search Engine" Value="0"></asp:ListItem>
                                                    <asp:ListItem Text="Online Banner Advertisement" Value="1"></asp:ListItem>
                                                    <asp:ListItem Text="Print" Value="2"></asp:ListItem>
                                                    <asp:ListItem Text="Sedalite Sales Representative" Value="3"></asp:ListItem>
                                                    <asp:ListItem Text="Colleague" Value="4"></asp:ListItem>
                                                </asp:DropDownList>
                                  
                                                                                       
                                            </td>
                                        </tr>--%>
                                   <%--     <tr>
                                            <td align="left" colspan="2" class="black_11px">
                                                <asp:CheckBox ID="CheckBox1"    runat="server" />
                                                   Yes, I agree to all the <a href="/KB/answers/salesPolicy.aspx">terms and conditions </a> stated herein.
                                            </td>
                                        </tr>--%>
                                    </table>
                                </td>
                            </tr>
                            <tr>
                                <td  height="30px" align="right">
                                
                                   <asp:Button ID="Button1"  CausesValidation="true"  ValidationGroup="RegEditvalidate"  CssClass="btnsbmit"   runat="server"
                                        Visible="true"></asp:Button>
                                </td>
                            </tr>
                        </table>
             
        </asp:Panel>
        <table width="100%" cellpadding="10px" cellspacing="0" border="0">
            <tr>
         <td>
                    <asp:Label ID="lblMsg" ForeColor="Red" runat="server"  CssClass="textRed"></asp:Label>
      </td>
            </tr>
        </table>
    </div>

</asp:Content>
Posted
Updated 12-Feb-12 22:46pm
v3
Comments
Sudip Saha 13-Feb-12 5:19am    
Can you please check your master page see if there more than form tag

Hello

Add onclick event on Button1, it will going to be work

Example

C#
<asp:button id="Button1" causesvalidation="true" validationgroup="RegEditvalidate" cssclass="btnsbmit" runat="server" visible="true" onclick="Button1_Click" xmlns:asp="#unknown"></asp:button>  
 
Share this answer
 
Comments
pawanvats 13-Feb-12 5:01am    
sorry ,but it is not working .i have tried almost everything.
Hello,do you have an event on Button1?you must add onclick event on Button1.
Ensure that all passed the valication.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900