|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
ControlToValidateHi There,
I am trying to implement the following criteria for the controltovalidate web control. If a checkbox is checked and a textbox is empty then accept the validation as true and process some code if the page is valid If a checkbox is unchecked and a textbox is empty then treat the validation as false and not allow to process some more code. Any ideas? Thanks, Kevin. Kevin Humphreys wrote:
> Hi There, Use CustomValidator.> I am trying to implement the following criteria for the controltovalidate > web control. > If a checkbox is checked and a textbox is empty then accept the validation > as true and process some code if the page is valid > If a checkbox is unchecked and a textbox is empty then treat the validation > as false and not allow to process some more code. > > Any ideas? > > Thanks, > Kevin. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolscustomvalidatorclasstopic.asp Hi,
Thanks for this. However the custom validator also validates based on 1 control only. I am trying to validate based on the criteria of 2 controls. Any Ideas? Thanks, Kevin. Show quoteHide quote "marss" <marss***@gmail.com> wrote in message news:1171528011.932166.287010@k78g2000cwa.googlegroups.com... > > Kevin Humphreys wrote: >> Hi There, >> I am trying to implement the following criteria for the controltovalidate >> web control. >> If a checkbox is checked and a textbox is empty then accept the >> validation >> as true and process some code if the page is valid >> If a checkbox is unchecked and a textbox is empty then treat the >> validation >> as false and not allow to process some more code. >> >> Any ideas? >> >> Thanks, >> Kevin. > > Use CustomValidator. > http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebuiwebcontrolscustomvalidatorclasstopic.asp > Kevin Humphreys wrote:
> Hi, Hi,> Thanks for this. However the custom validator also validates based on 1 > control only. > I am trying to validate based on the criteria of 2 controls. > > Any Ideas? > > Thanks, > Kevin. The CustomValidator implements custom validation irregardless of the control's number. Example. ..ascx <asp:CheckBox ID="CheckBox1" runat="server" /> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:CustomValidator ID="CustomValidator1" runat="server" ErrorMessage="Error!" OnServerValidate="CustomValidator1_ServerValidate"></ asp:CustomValidator> ..cs protected void CustomValidator1_ServerValidate(object source, ServerValidateEventArgs args) { if (CheckBox1.Checked) args.IsValid = TextBox1.Text.Length == 0; else args.IsValid = TextBox1.Text.Length > 0; } Regards, Mykola Got it. Thanks a lot.
Show quoteHide quote "marss" <marss***@gmail.com> wrote in message news:1171612467.298556.269520@v45g2000cwv.googlegroups.com... > > Kevin Humphreys wrote: >> Hi, >> Thanks for this. However the custom validator also validates based on 1 >> control only. >> I am trying to validate based on the criteria of 2 controls. >> >> Any Ideas? >> >> Thanks, >> Kevin. > > Hi, > The CustomValidator implements custom validation irregardless of the > control's number. > Example. > .ascx > <asp:CheckBox ID="CheckBox1" runat="server" /> > <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> > <asp:CustomValidator ID="CustomValidator1" runat="server" > ErrorMessage="Error!" > OnServerValidate="CustomValidator1_ServerValidate"></ > asp:CustomValidator> > > .cs > protected void CustomValidator1_ServerValidate(object source, > ServerValidateEventArgs args) > { > if (CheckBox1.Checked) > args.IsValid = TextBox1.Text.Length == 0; > else > args.IsValid = TextBox1.Text.Length > 0; > } > > Regards, > Mykola >
AJAX and embeded controls
menu navigation control and CSS interference how to change email defined when creating account? Script manager equivalent... How can I do? GridView Header Height why is this html table still visible? Put the date of today in a text control Datagrid HeaderStyle.CssClass applied to <tr> page is postback while using validation Should HeaderText change the behavior of a GridView? |
|||||||||||||||||||||||