Click here to Skip to main content
15,891,423 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi.
this is lokesh
my problem is i have 2 textboxes with 2 buttons but textbox1 should validate to button1 and textbox2 should validate to button2 in same page please

help me
Posted

set validationgroup=a property of Textbox1 and Button1
and do the same set validationgroup=b for Textbox2 and Button2.


Remember !! CausesValidation must be true for both buttons.(Button1 and Button2)


Make it solution if you got your answer.


Thanks
Ashish
 
Share this answer
 
v3
Comments
Rahul Rajat Singh 28-Jun-12 5:29am    
+5.
lokesh lokesh 6-Aug-12 22:39pm    
thanks its working
Read below article from MSDN and use validationGroup property


http://msdn.microsoft.com/en-us/library/ms227424.aspx[^]
 
Share this answer
 
i think this will help you,

C#
<asp:textbox id="TextBox1" runat="server"></asp:textbox>
        <asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" errormessage="1st one" validationgroup="1st" controltovalidate="TextBox1">
        </asp:requiredfieldvalidator>
        <asp:button id="Button1" runat="server" text="Button" validationgroup="1st" causesvalidation="true" /><br />

        <asp:textbox id="TextBox2" runat="server"></asp:textbox>
        <asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" errormessage="2nd one" validationgroup="2nd" controltovalidate="TextBox2">
        </asp:requiredfieldvalidator>
        <asp:button id="Button2" runat="server" text="Button" validationgroup="2nd" causesvalidation="true" />
 
Share this answer
 
v2
Step1:Place two text boxes and two buttons.
Step2:Put the validator u want and this has a property control to validate and give the name of textbox to validate and one more property validation group give any name and go to properties of button u want to validate this also has validation group property give the same name which you gave above.
Step3:Do the step 2 for other text box also
Step4:check it this will validate seperately..as u want
 
Share this answer
 
Make a two group for both textbox.
for txtbx1 and btn1 group t1 and txtbx2 and btn2 group 2.
then try to run .
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900