Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. blank forms submitting on server, all validations not working.

blank forms submitting on server, all validations not working.

Scheduled Pinned Locked Moved ASP.NET
sysadminhelp
18 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E er puneet

    hi himanshu, javascript is enabled in my browser. I have also checked it in mozilla, safari and chrome...same problem occured again. :(

    A Offline
    A Offline
    Abhijit Jana
    wrote on last edited by
    #7

    Do as I have suggested and validatge the Regx for Telephone number also.

    cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging

    1 Reply Last reply
    0
    • A Abhijit Jana

      Give Same ValidationGroup name to all the texbox Control, ValidationControl and the Submit Button Control. It should Work.

      cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging

      E Offline
      E Offline
      er puneet
      wrote on last edited by
      #8

      Hi Abhijit, I tried by giving the same validation group name to all the textboxes, validation controls and the button control. But, still the form is submitting blank.

      A 1 Reply Last reply
      0
      • E er puneet

        Hi Abhijit, I tried by giving the same validation group name to all the textboxes, validation controls and the button control. But, still the form is submitting blank.

        A Offline
        A Offline
        Abhijit Jana
        wrote on last edited by
        #9

        I did the same, and was working fine. By the way I removed the Regx For Telephone number an then tried.

        cheers, Abhijit CodeProject MVP Web Site:abhijitjana.net My Latest Article : IIS Remote Debugging

        1 Reply Last reply
        0
        • E er puneet

          Hi everyone, i have created a contact form in my website. The empty contact form is going to the server. I have also put validations on that form...but the validations are not working. Please help me in this regard.

          Z Offline
          Z Offline
          Zafar A khan
          wrote on last edited by
          #10

          Add the following to your web.config file </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </modules> <handlers> <remove name="WebServiceHandlerFactory-Integrated"/> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </handlers> </system.webServer>

          E 1 Reply Last reply
          0
          • Z Zafar A khan

            Add the following to your web.config file </system.web> <system.webServer> <validation validateIntegratedModeConfiguration="false"/> <modules> <add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </modules> <handlers> <remove name="WebServiceHandlerFactory-Integrated"/> <add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </handlers> </system.webServer>

            E Offline
            E Offline
            er puneet
            wrote on last edited by
            #11

            Hi Zafar, i have updated the web.config file with the code that mentioned in your reply...But, still it's not working. Can it be the problem with the server where the site is hosted??

            Z 1 Reply Last reply
            0
            • E er puneet

              Hi Zafar, i have updated the web.config file with the code that mentioned in your reply...But, still it's not working. Can it be the problem with the server where the site is hosted??

              Z Offline
              Z Offline
              Zafar A khan
              wrote on last edited by
              #12

              which version u r using 2005 or 2008. mention here. i will try to solve your problem and will post you the exact code. is it working on local ?

              E 1 Reply Last reply
              0
              • Z Zafar A khan

                which version u r using 2005 or 2008. mention here. i will try to solve your problem and will post you the exact code. is it working on local ?

                E Offline
                E Offline
                er puneet
                wrote on last edited by
                #13

                Hi Zafar, "which version u r using 2005 or 2008" I am using .Net (version 3.5) with Sql Server 2005 on my local machine. And on the web server we have .net (v 2.0) with sql server 2005. "is it working on local?" The code is working perfectly on local; but the problem occured when i tried to run it on web server.

                using System;
                using System.Collections;
                using System.Configuration;
                using System.Data;
                using System.Data.SqlClient;
                using System.Drawing;
                using System.Linq;
                using System.Net.Mail;
                using System.Web;
                using System.Text;
                using System.Web.Security;
                using System.Web.UI;
                using System.Web.UI.HtmlControls;
                using System.Web.UI.WebControls;
                using System.Web.UI.WebControls.WebParts;
                using System.Xml.Linq;

                public partial class Contact_Us : System.Web.UI.Page
                {
                protected void Page_Load(object sender, EventArgs e)
                {

                    if(!Page.IsPostBack)
                    {
                        About\_Data();
                    }
                }
                
                public void About\_Data()
                {
                    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings\["newcon"\].ConnectionString);
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = con;
                    cmd.CommandText = "select page\_text,heading from PAGES where pid='10'";
                    cmd.Connection.Open();
                    SqlDataReader rdr = cmd.ExecuteReader();
                    while (rdr.Read())
                    {
                        string ctext = rdr\["page\_text"\].ToString();
                        string htext = rdr\["heading"\].ToString();
                        LblText.Text = ctext;
                        LblHeading.Text = htext;
                    }
                    cmd.Connection.Close();
                }
                
                protected void BtnSubmit\_Click(object sender, EventArgs e)
                {
                    string y = BtnSubmit.ValidationGroup;
                    Page.Validate(y);
                    save\_to\_database();
                    send\_data\_to\_mail();
                    TxtName.Text = "";
                    TxtEmail.Text = "";
                    TxtPhone.Text = "";
                    TxtMessage.Text = "";
                }
                
                protected void BtnReset\_Click(object sender, EventArgs e)
                {
                    TxtName.Text = "";
                    TxtEmail.Text = "";
                    TxtPhone.Text = "";
                    TxtMessage.Text = "";
                }
                
                public void save\_to\_database()
                {
                
                    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings\["newcon"\].ConnectionString);
                    SqlCommand cmd = new SqlCommand();
                    cmd.Connection = con;
                    cmd.CommandText = "insert into CONTACTUS (name,email,phone,message) values(@name,@email,@phone,@message)";
                    cmd.Parameters.Add("@name", S
                
                Z 1 Reply Last reply
                0
                • E er puneet

                  Hi Zafar, "which version u r using 2005 or 2008" I am using .Net (version 3.5) with Sql Server 2005 on my local machine. And on the web server we have .net (v 2.0) with sql server 2005. "is it working on local?" The code is working perfectly on local; but the problem occured when i tried to run it on web server.

                  using System;
                  using System.Collections;
                  using System.Configuration;
                  using System.Data;
                  using System.Data.SqlClient;
                  using System.Drawing;
                  using System.Linq;
                  using System.Net.Mail;
                  using System.Web;
                  using System.Text;
                  using System.Web.Security;
                  using System.Web.UI;
                  using System.Web.UI.HtmlControls;
                  using System.Web.UI.WebControls;
                  using System.Web.UI.WebControls.WebParts;
                  using System.Xml.Linq;

                  public partial class Contact_Us : System.Web.UI.Page
                  {
                  protected void Page_Load(object sender, EventArgs e)
                  {

                      if(!Page.IsPostBack)
                      {
                          About\_Data();
                      }
                  }
                  
                  public void About\_Data()
                  {
                      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings\["newcon"\].ConnectionString);
                      SqlCommand cmd = new SqlCommand();
                      cmd.Connection = con;
                      cmd.CommandText = "select page\_text,heading from PAGES where pid='10'";
                      cmd.Connection.Open();
                      SqlDataReader rdr = cmd.ExecuteReader();
                      while (rdr.Read())
                      {
                          string ctext = rdr\["page\_text"\].ToString();
                          string htext = rdr\["heading"\].ToString();
                          LblText.Text = ctext;
                          LblHeading.Text = htext;
                      }
                      cmd.Connection.Close();
                  }
                  
                  protected void BtnSubmit\_Click(object sender, EventArgs e)
                  {
                      string y = BtnSubmit.ValidationGroup;
                      Page.Validate(y);
                      save\_to\_database();
                      send\_data\_to\_mail();
                      TxtName.Text = "";
                      TxtEmail.Text = "";
                      TxtPhone.Text = "";
                      TxtMessage.Text = "";
                  }
                  
                  protected void BtnReset\_Click(object sender, EventArgs e)
                  {
                      TxtName.Text = "";
                      TxtEmail.Text = "";
                      TxtPhone.Text = "";
                      TxtMessage.Text = "";
                  }
                  
                  public void save\_to\_database()
                  {
                  
                      SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings\["newcon"\].ConnectionString);
                      SqlCommand cmd = new SqlCommand();
                      cmd.Connection = con;
                      cmd.CommandText = "insert into CONTACTUS (name,email,phone,message) values(@name,@email,@phone,@message)";
                      cmd.Parameters.Add("@name", S
                  
                  Z Offline
                  Z Offline
                  Zafar A khan
                  wrote on last edited by
                  #14

                  you are using framework 3.5 on local while on server you are using 2.0 use the same on both. Validation don't depend on code behind. check the property CausesValidation="true" on submit or save button and also check the ValidationGroup is the same for all controls you want to validate (if u r using Val Group) i think it will solve your problem

                  E 1 Reply Last reply
                  0
                  • Z Zafar A khan

                    you are using framework 3.5 on local while on server you are using 2.0 use the same on both. Validation don't depend on code behind. check the property CausesValidation="true" on submit or save button and also check the ValidationGroup is the same for all controls you want to validate (if u r using Val Group) i think it will solve your problem

                    E Offline
                    E Offline
                    er puneet
                    wrote on last edited by
                    #15

                    Hi Zafar, i 've checked the code, causesvalidation property was true. I am posting the inline code here: <table align="center" class="appform" width="100%" cellpadding="2px" cellspacing="1px" border="0px"> <tr valign="top" align="left"> <td colspan="2"> <asp:Label ID="LblMsg" runat="server"></asp:Label> </td> <td>&nbsp; </td> </tr> <tr valign="top" align="left"> <td> Name:*</td> <td> <asp:TextBox ID="TxtName" runat="server" Width="270px" ValidationGroup="contact" CausesValidation="True"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtName" Display="Dynamic" ErrorMessage="*" ValidationGroup="contact"></asp:RequiredFieldValidator> </td> </tr> <tr valign="top" align="left"> <td> Email ID:*</td> <td> <asp:TextBox ID="TxtEmail" runat="server" Width="270px" ValidationGroup="contact"></asp:TextBox> </td> <td> &nbsp;</td> </tr> <tr valign="top" align="left"> <td> Phone Number:*</td> <td> <asp:TextBox ID="TxtPhone" runat="server" Width="270px" ValidationGroup="contact"></asp:TextBox> </td> <td> &nbsp;</td> </tr> <tr valign="top" align="left"> <td valign="top"> Message:*</td> <td> <asp:TextBox ID="TxtMessage" runat="server" TextMode="MultiLine" Width="270px" Height="150px" ValidationGroup="contact"></asp:TextBox> </td> <td valign="top"> &nbsp;</td> </tr> <tr valig

                    Z 1 Reply Last reply
                    0
                    • E er puneet

                      Hi Zafar, i 've checked the code, causesvalidation property was true. I am posting the inline code here: <table align="center" class="appform" width="100%" cellpadding="2px" cellspacing="1px" border="0px"> <tr valign="top" align="left"> <td colspan="2"> <asp:Label ID="LblMsg" runat="server"></asp:Label> </td> <td>&nbsp; </td> </tr> <tr valign="top" align="left"> <td> Name:*</td> <td> <asp:TextBox ID="TxtName" runat="server" Width="270px" ValidationGroup="contact" CausesValidation="True"></asp:TextBox> </td> <td> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TxtName" Display="Dynamic" ErrorMessage="*" ValidationGroup="contact"></asp:RequiredFieldValidator> </td> </tr> <tr valign="top" align="left"> <td> Email ID:*</td> <td> <asp:TextBox ID="TxtEmail" runat="server" Width="270px" ValidationGroup="contact"></asp:TextBox> </td> <td> &nbsp;</td> </tr> <tr valign="top" align="left"> <td> Phone Number:*</td> <td> <asp:TextBox ID="TxtPhone" runat="server" Width="270px" ValidationGroup="contact"></asp:TextBox> </td> <td> &nbsp;</td> </tr> <tr valign="top" align="left"> <td valign="top"> Message:*</td> <td> <asp:TextBox ID="TxtMessage" runat="server" TextMode="MultiLine" Width="270px" Height="150px" ValidationGroup="contact"></asp:TextBox> </td> <td valign="top"> &nbsp;</td> </tr> <tr valig

                      Z Offline
                      Z Offline
                      Zafar A khan
                      wrote on last edited by
                      #16

                      the code is working.. properly. there is no issue in your code. but the in the BtnReset set the CausesValidation="false" and in BtnSubmit set the CausesValidation="true" because no need of validation on Reset button. Use Same .net framework version on server and your development environment. (as you said that it is working on local) so its the issue on server.

                      E 1 Reply Last reply
                      0
                      • Z Zafar A khan

                        the code is working.. properly. there is no issue in your code. but the in the BtnReset set the CausesValidation="false" and in BtnSubmit set the CausesValidation="true" because no need of validation on Reset button. Use Same .net framework version on server and your development environment. (as you said that it is working on local) so its the issue on server.

                        E Offline
                        E Offline
                        er puneet
                        wrote on last edited by
                        #17

                        hello Zafar, Finally, the problem is solved. the problem was with the server. thanx a lot for your support... :)

                        Z 1 Reply Last reply
                        0
                        • E er puneet

                          hello Zafar, Finally, the problem is solved. the problem was with the server. thanx a lot for your support... :)

                          Z Offline
                          Z Offline
                          Zafar A khan
                          wrote on last edited by
                          #18

                          you are welcome :thumbsup:

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups