Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET
Ajax validation controls(RequiredFieldValidator) fired after code behind i.e is not called before code behind , so i have written the Page.Validate("Save"); in .cs for validation of aspx page controls But the problem is the entire code is locally running Very Fine , Not Working in Server Side (i.e., in Hoste site)
 
please suggest any solution.
 

I written the code like below
 

 




<td id="tdCountryWidth" runat="server" colspan="3" valign="top" align="left" width="380">

<asp:UpdatePanel ID="UpdatePanel2" runat="server">

<asp:PostBackTrigger ControlID="ddlCountry" />
<asp:PostBackTrigger ControlID="ddlState" />



Street Address*

:

<asp:TextBox ID="txtAddress" runat="server" CssClass="textfield" TabIndex="16" ToolTip="Please enter Street Address"
MaxLength="200" onkeyup="javascript:textchange();" ValidationGroup="Save">
<ajaxtoolkit:TextBoxWatermarkExtender ID="tbwmeaddr1" runat="server" TargetControlID="txtAddress"
WatermarkCssClass="watermarked" WatermarkText="Street Address" Enabled="True" />
<asp:RequiredFieldValidator ID="rfvregaddr1" runat="server" ControlToValidate="txtAddress"
Display="None" ErrorMessage="Street Address required" Font-Size="10px" SetFocusOnError="True"
ValidationGroup="Save">
<ajaxtoolkit:ValidatorCalloutExtender ID="vcerfvregaddr1" runat="server" CloseImageUrl="~/images/Closing.png"
TargetControlID="rfvregaddr1" WarningIconImageUrl="~/images/warning.png" Width="150px"
Enabled="True">



Suite/Apt

:

<asp:TextBox ID="txtRegAddr2" runat="server" CssClass="textfield" TabIndex="17" ToolTip="Please enter Suite/Apt"
onkeyup="javascript:textchange();">
<ajaxtoolkit:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender2" runat="server"
TargetControlID="txtRegAddr2" WatermarkCssClass="watermarked" WatermarkText="Suite/Apt"
Enabled="True" />


<tr valign="top" align="left" id="trcounrty" runat="server" visible="false">

Country*

:

<asp:DropDownList ID="ddlCountry" runat="server" ToolTip="Please select Country"
onkeyup="javascript:textchange();" AutoPostBack="true" TabIndex="18" CssClass="textfield"
OnSelectedIndexChanged="ddlCountry_SelectedIndexChanged" Enabled="true">


<asp:RequiredFieldValidator ID="rfvcountry" runat="server" ErrorMessage="Country required"
SetFocusOnError="True" ControlToValidate="ddlCountry" Font-Size="10px" Display="None"
InitialValue="0" ValidationGroup="Save">
<ajaxtoolkit:ValidatorCalloutExtender ID="vcecountry" runat="server" TargetControlID="rfvcountry"
WarningIconImageUrl="~/images/warning.png" CloseImageUrl="~/images/Closing.png"
Width="150px" Enabled="True">



City Name *

:


<asp:TextBox ID="txtCity" runat="server" MaxLength="100" CssClass="textfield" TabIndex="19"
onkeyup="javascript:textchange();" ToolTip="Please enter City Name" ValidationGroup="Save">
<ajaxtoolkit:TextBoxWatermarkExtender ID="tbwmecity" runat="server" TargetControlID="txtCity"
WatermarkCssClass="watermarked" WatermarkText="City Name" Enabled="True" />
<asp:RequiredFieldValidator ID="rfvcity" runat="server" ErrorMessage="City required"
SetFocusOnError="True" ControlToValidate="txtCity" Font-Size="10px" Display="None"
ValidationGroup="Save">
<ajaxtoolkit:ValidatorCalloutExtender ID="vce16" runat="server" TargetControlID="rfvcity"
WarningIconImageUrl="~/images/warning.png" CloseImageUrl="~/images/Closing.png"
Width="150px" Enabled="True">



State*

:

<asp:DropDownList ID="ddlState" runat="server" ToolTip="Please select State" TabIndex="20"
onkeyup="javascript:textchange();" CssClass="textfield" ValidationGroup="Save">

<asp:RequiredFieldValidator ID="rfvstate" runat="server" ErrorMessage="State required"
SetFocusOnError="True" ControlToValidate="ddlState" Font-Size="10px" Display="None"
InitialValue="0" ValidationGroup="Save">
<ajaxtoolkit:ValidatorCalloutExtender ID="vcestate" runat="server" TargetControlID="rfvstate"
WarningIconImageUrl="~/images/warning.png" CloseImageUrl="~/images/Closing.png"
Width="150px" Enabled="True">







Zip Code*

:

<asp:TextBox ID="txtPincode" runat="server" MaxLength="10" CssClass="textfield" onkeyup="javascript:textchange();"
TabIndex="21" ToolTip="Please enter Zip Code" ValidationGroup="Save" >
<ajaxtoolkit:TextBoxWatermarkExtender ID="tbwmezip" runat="server" TargetControlID="txtPincode"
WatermarkCssClass="watermarked" WatermarkText="Zip Code" Enabled="True" />

<asp:RequiredFieldValidator ID="rfvzipcode" runat="server" ErrorMessage="Zipcode required"
SetFocusOnError="True" ControlToValidate="txtPincode" Font-Size="10px" Display="None"
ValidationGroup="Save">
<ajaxtoolkit:ValidatorCalloutExtender ID="vcezipcode" runat="server" TargetControlID="rfvzipcode"
WarningIconImageUrl="~/images/warning.png" CloseImageUrl="~/images/Closing.png"
Width="150px" Enabled="True">





<asp:HiddenField ID="hfSearchFromDate" runat="server" />

 

 

 
<asp:Button ID="btnSubmit" runat="server" CssClass="searchbg" OnClick="btnSubmit_Click" OnClientClick="javascript:return checkMinLength();"
TabIndex="34" Text="Submit" ToolTip="Click here to Submit" CausesValidation="true"
ValidationGroup="Save" />
 

 

Code behind button click event (.cs):
 

Page.Validate("Save");
 if (!Page.IsValid)
 {
     return;
 }
 
 bool val = false;
 lblStatus.Visible = false;
 if (btnSubmit.Text == "Submit" || btnSubmit.Text == "Update")
 {
     
     if (chkaddress.Checked == true)
     {
         chkaddress.Text = "true";
     }
     
    
 }
 
 
     PhoneNumber = txtMobile.Text;
     int length = PhoneNumber.Length;
     PhoneNumber1 = txtMobile1.Text;
     int length1 = PhoneNumber1.Length;
     PhoneNumber2 = txtMobile2.Text;
     int length2 = PhoneNumber2.Length;
 

     PhoneNumberCR = txtLandline.Text;
     int length3 = PhoneNumberCR.Length;
     PhoneNumberCR1 = txtLandline1.Text;
     int length4 = PhoneNumberCR1.Length;
     PhoneNumberCR2 = txtLandline2.Text;
     int length5 = PhoneNumberCR2.Length;
 
     if (length == 3 && length1 == 3 && length2 == 4 && length3 == 3 && length4 == 3 && length5 == 4)
     {
         string strEncryptPwd = string.Empty;
         if (ViewState["upass"] != null && ViewState["uname"] != null)
         {
             string strPassword = "¶¾±";
             strPassword += ViewState["upass"].ToString().Trim().ToLower();
             strPassword += "¶¾±";
             strPassword += ViewState["uname"].ToString().Trim().ToLower();
             strPassword += "¶¾±";
             strEncryptPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword, "md5");
         }
         else
         {
             ViewState["uname"] = txtUserName.Text;
             string strPassword = "¶¾±";
             strPassword += txtUserName.Text.ToString().Trim().ToLower();
             strPassword += "¶¾±";
             strPassword += txtPassword.Text.ToString().Trim().ToLower();
             strPassword += "¶¾±";
             strEncryptPwd = FormsAuthentication.HashPasswordForStoringInConfigFile(strPassword, "md5");
         }
Posted 13-Jul-13 5:56am
Edited 14-Jul-13 20:44pm
v6
Comments
dholakiya ankit at 13-Jul-13 13:22pm
   
post some ur code for this and check validation group also

1 solution

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

Solution 1

Check whether you have added ScriptManger properly.
 
Below article explains how to use RequiredFieldExtender.Check this.
 
http://requiredfieldextende.codeplex.com/[^]
 
I hope this will help to you.
  Permalink  

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

  Print Answers RSS
0 Kornfeld Eliyahu Peter 275
1 Maciej Los 204
2 Sergey Alexandrovich Kryukov 200
3 King Fisher 185
4 OriginalGriff 183
0 OriginalGriff 6,223
1 DamithSL 4,724
2 Maciej Los 4,196
3 Kornfeld Eliyahu Peter 3,894
4 Sergey Alexandrovich Kryukov 3,496


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 15 Jul 2013
Copyright © CodeProject, 1999-2014
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