Hi Shivani ,
set EnableClientScript=false for RequiredValidator
Retrive RequiredValidator error message in lable
Label1.text=RequiredValidator1.errormessage.tostring()
Example:--
1 button , 2 textbox , 1 label , 2 requiredfieldvalidation(set proeperty EnableClientScript=false )
---------------------------------------
HTML CODE
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="Label" Width="533px" BackColor="#FFE0C0" ></asp:Label>
<table>
<tr>
<td style="width: 143px">
</td>
<td style="width: 100px">
</td>
<td style="width: 100px">
</td>
</tr>
<tr>
<td style="width: 143px">
Employee Name</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox></td>
<td style="width: 100px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="TextBox1"
ErrorMessage="Enter employee name" Width="138px" EnableClientScript="False"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 143px">
Age</td>
<td style="width: 100px">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox></td>
<td style="width: 100px">
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox2"
ErrorMessage="Enter Age" EnableClientScript="False"></asp:RequiredFieldValidator></td>
</tr>
<tr>
<td style="width: 143px">
</td>
<td style="width: 100px">
<asp:Button ID="Button1" runat="server" Text="Submit" /></td>
<td style="width: 100px">
</td>
</tr>
</table>
</div>
</form>
----------------------------------------------------------------------------
CODE BEHIND PART:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
If IsValid = False Then
Label1.Text = RequiredFieldValidator1.ErrorMessage.ToString()
End If
end sub
--------------------------------------------------------------------------------
Hope it will Help You
Shivanichhabra4u, if this helps please login to Mark As Answer. | Alert Moderator