Required Field Validator is not working!!! [Resolved]

Posted by Sathiya_Narayanan under ASP.NET AJAX on 8/2/2012 | Points: 10 | Views : 37804 | Status : [Member] | Replies : 5
Hi,
Validations is not working. My application is from the retrieving data from database and when we click the Edit button in the grid the datas are shown in the AJAX popup box to update the data. its working good when update button clicks its update the data..
when i placed the required field validator control for every textbox though the textbox is Empty also its updating the data to database.

Required field validator property

<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="txtname" ValidationGroup="val">*</asp:RequiredFieldValidator>

If the field is empty update button should not work, but its working here

SATHIYANARAYANAN


Responses

Posted by: Ogipansrk on: 8/2/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
There is no problem with your posted code.
May be , for your 'Update Button" , there is a chance that you haven't set ValidationGroup properly.
use the same ValidationGroup Name , metioned in above code.

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ogipansrk on: 8/2/2012 [Member] Starter | Points: 25

Up
0
Down
can you post your source code

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sathiya_Narayanan on: 8/2/2012 [Member] Starter | Points: 25

Up
0
Down
<tr>
<td align="left" style="width: 150px; text-align: left;">
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

<asp:Label ID="lblname" runat="server" Text="Name:" Width="43px"></asp:Label></td>
<td style="text-align: center">
<asp:TextBox ID="txtname" runat="server" CausesValidation="True" ValidationGroup="val"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="txtname" ValidationGroup="val">*</asp:RequiredFieldValidator></td>
</tr>
<tr>
<td align="left" style="width: 150px; text-align: left;">
&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;

<asp:Label ID="lblNUM" runat="server" Text="NUM:" Width="43px"></asp:Label></td>
<td style="text-align: center">
<asp:TextBox ID="txtnum" runat="server" CausesValidation="True" ValidationGroup="val"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="txtnum" ValidationGroup="val">*</asp:RequiredFieldValidator></td>
</tr>

SATHIYANARAYANAN

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sathiya_Narayanan on: 8/2/2012 [Member] Starter | Points: 25

Up
0
Down
Thank you!! its works now..

SATHIYANARAYANAN

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ranjeet_8 on: 8/2/2012 [Member] [MVP] Gold | Points: 25

Up
0
Down
plz set Validation Group Property on your Update Button
for eg:

   <asp:Button ID="Button1" runat="server" Text="Update Button" ValidationGroup="val" />

ValidationGroup="val"

.

Sathiya_Narayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response