Hi,
I am Asha Bhatt.
I am making simple form in asp.net and validation in java script.

we this is my .aspx.cs code

using System.Data.SqlClient;

public partial class InterviewSet : System.Web.UI.Page
{
    string scon = "Data Source=RBWORKSTATION2\\SQLEXPRESS;Initial Catalog=onlineexamdb;Integrated Security=True;MultipleActiveResultSets=true";
   //SqlDataAdapter da;
    SqlCommand cmd;
   // DataSet ds;
    SqlDataReader readsid;
    public string sid, uid;
    public string time;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            TimeCheckBox.Checked = false;
        }
        
    }
    protected void AddButton_Click(object sender, EventArgs e)
    {

        if (Convert.ToInt32((Convert.ToInt32(Easyqus.Text) * 100) / 100) + ((Convert.ToInt32(Mediumqus.Text) * 100) / 100) + ((Convert.ToInt32(Hardqus.Text) * 100) / 100) != 100)
        {
            ErrorAddTextLabel.Visible = true;
        }
        else
        {
            ErrorAddTextLabel.Visible = false;
        }
        

        SqlConnection con = new SqlConnection(scon);
        try
        {
            con.Open();
            cmd = new SqlCommand("select SubID from SubjectInfo where SubID = (select MAX(SubID) from SubjectInfo )", con);
            readsid = cmd.ExecuteReader();
            while (readsid.Read())
            {
                sid = readsid[0].ToString();
                //  Response.Write(sid);
            }
            time = DateTime.Now.ToString("T");
            cmd = new SqlCommand("insert into TestInfo values(' " + Testname.Text + " '," + NoQus.Text + " , " + sid + " , " + Easyqus.Text + " , " + Mediumqus.Text + " , " + Hardqus.Text + " , " + Passmarks.Text + " , ' " + TimeTextBox.Text + " ')", con);
            cmd.ExecuteScalar();
            Response.Write("<script>alert('Your record is insert successfuly')</script>");
        }
        catch (Exception ex)
        {
            con.Close();
          //  Response.Write(ex.Message);
        }
 protected void TimeCheckBox_CheckedChanged(object sender, EventArgs e)
    {
        if (TimeCheckBox.Checked)
        {
            TimeTextBox.Visible = true;
            if (TimeTextBox.Text.Length > 59)
            {
                // Response.Write("<script>alert('Test Time can not be blank')</script>");
               // TimeErrorLabel.Visible = true;
                RangeValidator1.Visible = true;
            }
            
        }
        else
        {
            TimeTextBox.Visible = false;
            TimeErrorLabel.Visible = false;
        }
    }

and this is javascript code

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <html>
    <head>
    <title></title>
    <script type="text/javascript" language="javascript">
        
        function validate()
        {
                var num = /^\d{1,3}$/;
                var Qnum = document.getElementById("<%=NoQus.ClientID%>").value;
                var Enum = document.getElementById("<%=Easyqus.ClientID%>").value;
                var Mnum = document.getElementById("<%=Mediumqus.ClientID%>").value;
                var Hnum = document.getElementById("<%=Hardqus.ClientID%>").value;
                var Pnum = document.getElementById("<%=Passmarks.ClientID%>").value;
                var matchQnum = Qnum.match(num);
                var matchEnum = Enum.match(num);
                var matchMnum = Mnum.match(num);
                var matchHnum = Hnum.match(num);
                var matchPnum = Pnum.match(num);
               
            if(document.getElementById("<%=Testname.ClientID %>").value=="")
            {
                 alert("Test Name can not be blank");
                 document.getElementById("<%=Testname.ClientID %>").focus();
                 return false;
             }    
             else if (document.getElementById("<%=NoQus.ClientID%>").value=="")
            {
                 alert("Number of Question can not be blank");
                 document.getElementById("<%=NoQus.ClientID%>").focus();
                 return false;
            }
            else if(matchQnum == null)
            {
                 alert("Number of Question contains only 3 digit number not character.");
                 document.getElementById("<%=NoQus.ClientID %>").focus();
                 return false; 
            }
            
            else if (document.getElementById("<%=Easyqus.ClientID%>").value=="")
            {
                 alert("Easy Difficulty Lavel can not be blank");
                 document.getElementById("<%=Easyqus.ClientID%>").focus();
                 return false;
            }
            else if(matchEnum == null)
            {
                 alert("Easy Difficulty Lavel contains only 3 digit number not character.");
                 document.getElementById("<%=Easyqus.ClientID %>").focus();
                 return false; 
            }
            else if (document.getElementById("<%=Mediumqus.ClientID%>").value=="")
            {
                 alert("Medium Difficulty Lavel can not be blank");
                 document.getElementById("<%=Mediumqus.ClientID%>").focus();
                 return false;
            }
            else if(matchMnum == null)
            {
                 alert("Medium Difficulty Lavel contains only 3 digit number not character.");
                 document.getElementById("<%=Mediumqus.ClientID %>").focus();
                 return false; 
            }
            else if (document.getElementById("<%=Hardqus.ClientID%>").value=="")
            {
                 alert("Hard Difficulty Level can not be blank");
                 document.getElementById("<%=Hardqus.ClientID%>").focus();
                 return false;
            }
            else if(matchHnum == null)
            {
                 alert("Hard Difficulty Level contains only 3 digit number not character.");
                 document.getElementById("<%=Hardqus.ClientID %>").focus();
                 return false; 
            }
             else if (document.getElementById("<%=Subject.ClientID%>").value=="Select")
            {
                 alert("Select the Subject Name");
                 document.getElementById("<%=Subject.ClientID%>").focus();
                 return false;
            }
            else if (document.getElementById("<%=Passmarks.ClientID%>").value=="")
            {
                 alert("Passing Marks can not be blank");
                 document.getElementById("<%=Passmarks.ClientID%>").focus();
                 return false;
            }
             else if(matchPnum == null)
            {
                 alert("Passing Marks contains only number.");
                 document.getElementById("<%=Passmarks.ClientID %>").focus();
                 return false; 
            }
    
            else if (!document.getElementById("<%=TimeCheckBox.ClientID%>").checked)
             {
                document.getElementById("<%=TimeCheckBox.ClientID %>").focus();
                return false;
             }
             else if (document.getElementById("<%=TimeTextBox.ClientID%>").value=="")
             {
                alert("Timed Test can not be blank");
                document.getElementById("<%=TimeTextBox.ClientID%>").focus();
                return false;
             }
             else if (document.getElementById("<%=TimeTextBox.ClientID%>").value <0 || document.getElementById("<%=TimeTextBox.ClientID%>").value > 59)
             {
                alert("Test time must be in minits (0 - 59)");
                document.getElementById("<%=TimeTextBox.ClientID%>").focus();
                return false;
             }
          }
           
   
           
         </script>
   
</head>
<body>
    <table style="width: 100%; background-color: #FFFFFF;">
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                &nbsp;</td>
<td class="style8">
                <asp:Label ID="ErrorAddTextLabel" runat="server" Font-Bold="False" 
                    Font-Size="Medium" ForeColor="#DF0000" Height="16px" 
                    Text="The Addition of  Easy , Medium and Hard value should be 100" 
                    Visible="False" Width="414px" Font-Underline="False"></asp:Label>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                <asp:Label ID="Label13" runat="server" Font-Bold="False" 
                                        Font-Names="Georgia" Font-Size="Medium" ForeColor="Maroon" 
                                        Text="Test Name  :"></asp:Label>
            </td>
            <td class="style8">
                <asp:TextBox ID="Testname" runat="server" Width="215px" AutoPostBack="True" 
                    CausesValidation="True"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                <asp:Label ID="Label14" runat="server" Font-Names="Georgia" 
                                        Font-Size="Medium" ForeColor="Maroon" 
                    Text="Number of Question :" Width="153px"></asp:Label>
            </td>
            <td class="style8">
                <asp:TextBox ID="NoQus" runat="server" Width="215px" AutoPostBack="True" 
                    CausesValidation="True"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                <asp:Label ID="Label15" runat="server" Font-Names="Georgia" 
                                        Font-Size="Medium" ForeColor="Maroon" 
                    Text="Difficulty Level   :" Width="126px"></asp:Label>
            </td>
            <td class="style7">
                <asp:Label ID="Label26" runat="server" Font-Names="Georgia" Font-Size="Medium" 
                    ForeColor="Maroon" Text="  Easy  (%)   :"></asp:Label>
            </td>
            <td class="style8">
                <asp:TextBox ID="Easyqus" runat="server" Width="215px" AutoPostBack="True" 
                    CausesValidation="True"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style14">
                </td>
            <td class="style15">
                <asp:Label ID="Label27" runat="server" Font-Names="Georgia" Font-Size="Medium" 
                    ForeColor="Maroon" Text="  Medium  (%)   :"></asp:Label>
            </td>
            <td class="style16">
                <asp:TextBox ID="Mediumqus" runat="server" Width="215px" AutoPostBack="True" 
                    CausesValidation="True"></asp:TextBox>
            </td>
            <td class="style17">
                </td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                <asp:Label ID="Label28" runat="server" Font-Names="Georgia" Font-Size="Medium" 
                    ForeColor="Maroon" Text="  Hard   (%) :"></asp:Label>
            </td>
            <td class="style8">
                <asp:TextBox ID="Hardqus" runat="server" Width="215px" AutoPostBack="True" 
                    CausesValidation="True"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
            <asp:Label ID="Label2" runat="server" Text="Subject Name  :" Font-Names="Georgia" 
                    Font-Size="Medium" ForeColor="Maroon"></asp:Label>
            </td>
            <td class="style8">
            <asp:DropDownList ID="Subject" runat="server" Height="22px" Width="220px"   
                AutoPostBack="True" DataSourceID="SqlSubjectDataSource" 
                    DataTextField="SubjectName" DataValueField="SubjectName" 
                    CausesValidation="True" 
                    onselectedindexchanged="Subject_SelectedIndexChanged">
                         <asp:ListItem>Select</asp:ListItem>
                         <asp:ListItem>C#</asp:ListItem>
                         <asp:ListItem>PHP</asp:ListItem>
                         <asp:ListItem>ASP.NET</asp:ListItem>
                         <asp:ListItem Text= "true">Other</asp:ListItem>
                         
                         </asp:DropDownList>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                                    <asp:Label ID="Label29" runat="server" Font-Names="Georgia" Font-Size="Medium" 
                                        ForeColor="Maroon" Text="Passing Marks  :"></asp:Label>
            </td>
            <td class="style8">
                <asp:TextBox ID="Passmarks" runat="server" 
                    ontextchanged="Passmarks_TextChanged" Width="215px" AutoPostBack="True" 
                    CausesValidation="True"></asp:TextBox>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                                    &nbsp;</td>
            <td class="style8">
                <table style="width:216%;">
                    <tr>
                        <td align="left" class="style11">
                            <asp:CheckBox ID="TimeCheckBox" runat="server" AutoPostBack="True" 
                                CausesValidation="True" oncheckedchanged="TimeCheckBox_CheckedChanged" 
                                Text="Timed Test" Width="100px"  />
                        </td>
                        <td class="style12">
                            <asp:TextBox ID="TimeTextBox" runat="server" Visible="False" Width="110px" 
                                AutoPostBack="True" CausesValidation="True" 
                                ontextchanged="TimeTextBox_TextChanged" ></asp:TextBox>
                        </td>
                        <td>
                            <asp:Label ID="TimeErrorLabel" runat="server" ForeColor="#F00000" Height="17px" 
                                Text="Times for the Test should not be Blank" Visible="False" 
                                Width="325px"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td align="left" class="style11">
                            &nbsp;</td>
                        <td class="style12">
                            &nbsp;</td>
                        <td>
                            <asp:RangeValidator ID="RangeValidator1" runat="server" 
                                ControlToValidate="TimeTextBox" 
                                ErrorMessage="Times must be in minute  between 0 and 59" MaximumValue="59" 
                                MinimumValue="0" Type="Integer" Width="432px" 
                                CultureInvariantValues="True" SetFocusOnError="True" Visible="False"></asp:RangeValidator>
                        </td>
                    </tr>
                </table>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                                    &nbsp;</td>
            <td class="style8">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7" align="right">
                <asp:Button ID="Button10" runat="server" Font-Size="Medium" Height="28px" 
                    PostBackUrl="~/SetUpTest.aspx" Text="  Back  " Width="80px" />
            </td>
            <td class="style8">
                <asp:Button ID="AddButton" runat="server" Font-Size="Medium" 
                    onclick="AddButton_Click" Text="Add   "  
                    onclientclick="javascript: return validate()"  Width="80px" />
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                <asp:SqlDataSource ID="SqlSubjectDataSource" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:onlineexamdbConnectionString %>" 
                    SelectCommand="SELECT [SubjectName] FROM [SubjectInfo]"></asp:SqlDataSource>
            </td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td class="style9">
                &nbsp;</td>
            <td class="style7">
                &nbsp;</td>
            <td class="style8">
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
    </table>
    </body>
    </html>
</asp:Content>

my prblem is that when i run this page that time
I fill up the information abt our requriement in the textbox that time
when i fill the information in 1st textbox then when i will click on the 2nd textbox that time my page gets too much of time for loading.
the page is load again and agian to fill the information in each and every , so its take too much of time to fill the small form.

Plaese tell me the solucation .

Thank you.

Turn off AutoPostBack property.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.