Click here to Skip to main content
12,620,909 members (31,740 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# ASP.NET
When I disable the Javascript in the browser and without filling the fields I click the submit button then I cant see the Server Side Validation message, whats wrong with the below code?

<asp:Panel ID="Panel1" runat="server">
            <table class="style4">
             <tr>
                 <td class="style9">
                     <asp:Label ID="Label2" runat="server" Text="Name" Font-Bold="True" ForeColor="#FFD028">
                 </td>
                 <td class="style10">
                     <asp:TextBox ID="TxtName" runat="server" CssClass="Roundedcorner" 
                         ToolTip="Name" CausesValidation="True">
                 </td>
                 <td class="style11">
                      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                          ControlToValidate="TxtName" ErrorMessage="*" ValidationGroup="Contact" 
                          Display="Dynamic">Please 
                      fill  <asp:RegularExpressionValidator 
                          ID="RegularExpressionValidator1" runat="server"
                         ErrorMessage="*" ControlToValidate="TxtName" Display="Dynamic" 
                          ValidationExpression="^([a-zA-z\s]{2,32})$" ValidationGroup="Contact">Alphabets only
                 </td>
             </tr>
             <tr>
                 <td class="style8">
                     <asp:Label ID="Label3" runat="server" Text="Email Id" Font-Bold="True" ForeColor="#FFD028">
                 </td>
                 <td class="style7">
                     <asp:TextBox ID="TxtEmail" runat="server" CssClass="Roundedcorner" 
                         ToolTip="Email Id" CausesValidation="True">
                 </td>
                 <td>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                         ControlToValidate="TxtEmail" Display="Dynamic" ErrorMessage="*" 
                         ToolTip="Email Id" ValidationGroup="Contact">Please fill
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" 
                         ControlToValidate="TxtEmail" Display="Dynamic" ErrorMessage="*" 
                         ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" 
                         ValidationGroup="Contact">
                 </td>
             </tr>
             <tr>
                 <td class="style8">
                     <asp:Label ID="Label4" runat="server" Text="Contact Number" Font-Bold="True" ForeColor="#FFD028">
                 </td>
                 <td class="style7">
                     <asp:TextBox ID="TxtContact" runat="server" CssClass="Roundedcorner" 
                         ToolTip="Contact Number" CausesValidation="True">
                 </td>
                 <td>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" 
                         ControlToValidate="TxtContact" ErrorMessage="*" ValidationGroup="Contact" 
                         Display="Dynamic">Please 
                     fill
                     <asp:RegularExpressionValidator ID="RegularExpressionValidator3" runat="server" 
                         Display="Dynamic" ErrorMessage="*" ValidationExpression="^[0-9]{6,10}$" 
                         ControlToValidate="TxtContact">Numbers 
                     only
                 </td>
             </tr>
             <tr>
                 <td class="style8">
                     <asp:Label ID="Label5" runat="server" Text="Your Message" Font-Bold="True" Font-Italic="False"
                         Font-Strikeout="False" Font-Underline="False" ForeColor="#FFD028">
                 </td>
                 <td class="style7">
                     <asp:TextBox ID="TxtMessage" runat="server" CssClass="Roundedcorner" 
                         TextMode="MultiLine" Width="131px" ToolTip="Feedback Message" 
                         CausesValidation="True">
                 </td>
                 <td>
                     <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" 
                         ControlToValidate="TxtMessage" Display="Dynamic" ErrorMessage="*" 
                         ValidationGroup="Contact">Cannot be blank
                 </td>
             </tr>
             <tr><td colspan="3"></td></tr>
             <tr>
                 <td class="style8">
                       </td>
                 <td class="style7">
                     <asp:Button ID="BtnSubmit" runat="server" CssClass="css3button" Text="Submit"
                         OnClick="BtnSubmit_Click1" ValidationGroup="Contact" Height="34px" 
                         Width="94px" />
                 </td>
                 <td>
                      
                 </td>
             </tr>
             <tr>
                 <td class="style8">
                      
                 </td>
                 <td class="style7">
                    
                 </td>
                 <td>
                      
                 </td>
             </tr>
         </table>
        <asp:Panel ID="Panel2" runat="server" 
                   style="top: 95px; left: 38px; position: absolute; height: 19px; width: 321px">
               <br />
             
                   <table>
                   <tr><td><asp:Image ID="Image2" runat="server" ImageUrl="images/Right1.png" Height="33px" 
                   Width="46px" /></td>
                   <td><p style="font-size:11pt;font-family:Comic Sans MS; color: #FFD028; font-weight: 700;">We have received your feedback</p></td>
                   </tr>
                   </table>
Posted 2-Feb-13 21:49pm
Updated 2-Feb-13 22:08pm
v2
Comments
Sandeep Mewara 3-Feb-13 3:11am
   
You say, on disabling JS you cant see the Server Side Validation message?
In other words, whole page is re-rendered post postback and yet you fail to see the message set by server?
DevashishDas 4-Feb-13 10:45am
   
Yes, am using a panel to display the successful message to the user and the first panel is hidden when all the details are filled correctly, as the user gets a Thankyou mail with the success message. Is it because of the panels?

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

As far as I remember postback on the client side is handled via .NET auto-generated JavaScript, having JS disabled seems like a way to sterilize the browser.

I doubt if you could get a functional ASP.NET page without JS, unless you are using silverlight, flash, applets or another solution.

Cheers,
Edo
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.161128.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100