need to have 'validation group'

Discussion in 'ASP .Net' started by Lloyd Dupont, Feb 22, 2006.

  1. Lloyd Dupont

    Lloyd Dupont Guest

    On my page the user is ask to set of question.
    Say there I have 2 controls like that
    == pseudo-C#-code for my control ==
    class MyControl : CompositeControl
    {
    TextBox text;
    LinkButton button

    override void CreateChildControl()
    {
    text = new TextBox();
    text.ID = "text"
    Controls.Add(text);

    button = new LinkButton();
    buton.Text = submit;
    button.Click = HCSubmit;
    button.ID = "submit";

    // == problem here
    RequieredFieldValidator rfv = new RequiredFieldValidator();
    rfv.ControlToVerify = "text";
    Control.Add(rfv);
    }
    }
    As you could see, text should have some value in it.
    Now let's say I have 2 such control on the page and the user fill one and
    press the submit link button, it won't be able to submit because the other
    field would be empty.
    Which is annoying.

    Is there a way to limit the scope of the required field validator?
    I coukld just remove it, but it provide nice features, so I'm wondering if
    there is a solution to this problem, I have heard that ASP.NET 2.0 solve
    it...
     
    Lloyd Dupont, Feb 22, 2006
    #1
    1. Advertising

  2. In ASP.NET 2.0 there are validation groups which do exactly what you want.
    For ASP.NET 1.x you are going to have to be more creative, using custom
    validators rather than required field validators.



    "Lloyd Dupont" <net.galador@ld> wrote in message
    news:...
    > On my page the user is ask to set of question.
    > Say there I have 2 controls like that
    > == pseudo-C#-code for my control ==
    > class MyControl : CompositeControl
    > {
    > TextBox text;
    > LinkButton button
    >
    > override void CreateChildControl()
    > {
    > text = new TextBox();
    > text.ID = "text"
    > Controls.Add(text);
    >
    > button = new LinkButton();
    > buton.Text = submit;
    > button.Click = HCSubmit;
    > button.ID = "submit";
    >
    > // == problem here
    > RequieredFieldValidator rfv = new RequiredFieldValidator();
    > rfv.ControlToVerify = "text";
    > Control.Add(rfv);
    > }
    > }
    > As you could see, text should have some value in it.
    > Now let's say I have 2 such control on the page and the user fill one and
    > press the submit link button, it won't be able to submit because the other
    > field would be empty.
    > Which is annoying.
    >
    > Is there a way to limit the scope of the required field validator?
    > I coukld just remove it, but it provide nice features, so I'm wondering if
    > there is a solution to this problem, I have heard that ASP.NET 2.0 solve
    > it...
    >
     
    Jesse Liberty, Feb 22, 2006
    #2
    1. Advertising

  3. Lloyd Dupont

    Lloyd Dupont Guest

    > In ASP.NET 2.0 there are validation groups which do exactly what you want.
    Allright...
    How does that work?

    > For ASP.NET 1.x you are going to have to be more creative, using custom
    > validators rather than required field validators.
    >
    >
    >
    > "Lloyd Dupont" <net.galador@ld> wrote in message
    > news:...
    >> On my page the user is ask to set of question.
    >> Say there I have 2 controls like that
    >> == pseudo-C#-code for my control ==
    >> class MyControl : CompositeControl
    >> {
    >> TextBox text;
    >> LinkButton button
    >>
    >> override void CreateChildControl()
    >> {
    >> text = new TextBox();
    >> text.ID = "text"
    >> Controls.Add(text);
    >>
    >> button = new LinkButton();
    >> buton.Text = submit;
    >> button.Click = HCSubmit;
    >> button.ID = "submit";
    >>
    >> // == problem here
    >> RequieredFieldValidator rfv = new RequiredFieldValidator();
    >> rfv.ControlToVerify = "text";
    >> Control.Add(rfv);
    >> }
    >> }
    >> As you could see, text should have some value in it.
    >> Now let's say I have 2 such control on the page and the user fill one and
    >> press the submit link button, it won't be able to submit because the
    >> other field would be empty.
    >> Which is annoying.
    >>
    >> Is there a way to limit the scope of the required field validator?
    >> I coukld just remove it, but it provide nice features, so I'm wondering
    >> if there is a solution to this problem, I have heard that ASP.NET 2.0
    >> solve it...
    >>

    >
    >
     
    Lloyd Dupont, Feb 22, 2006
    #3
  4. Lloyd Dupont

    Peter Blum Guest

    Hi Lloyd,

    There are a couple of solutions for ASP.NET 1.1:

    1. Use server side validation when the page is submitted to fire the
    Validate() method of only the desired validators. This article -
    http://aspalliance.com/699 - shows you how (along with many other validation
    questions). See the topic "Several buttons associated with their own
    validators".

    2. I built a replacement to the ASP.NET validators that fixes the many
    limitations I've found. Its called "Professional Validation And More" (
    http://www.peterblum.com/vam/home.aspx ). My validators have validation
    groups. You simply assign a group name to the Group property on the submit
    button and the associated validators. There are an enormous number of other
    improvements I've made to validation and I include a utility to quickly
    convert a page from your existing validators to mine.

    --- Peter Blum
    www.PeterBlum.com
    Email:
    Creator of "Professional Validation And More" at
    http://www.peterblum.com/vam/home.aspx

    "Lloyd Dupont" <net.galador@ld> wrote in message
    news:...
    > On my page the user is ask to set of question.
    > Say there I have 2 controls like that
    > == pseudo-C#-code for my control ==
    > class MyControl : CompositeControl
    > {
    > TextBox text;
    > LinkButton button
    >
    > override void CreateChildControl()
    > {
    > text = new TextBox();
    > text.ID = "text"
    > Controls.Add(text);
    >
    > button = new LinkButton();
    > buton.Text = submit;
    > button.Click = HCSubmit;
    > button.ID = "submit";
    >
    > // == problem here
    > RequieredFieldValidator rfv = new RequiredFieldValidator();
    > rfv.ControlToVerify = "text";
    > Control.Add(rfv);
    > }
    > }
    > As you could see, text should have some value in it.
    > Now let's say I have 2 such control on the page and the user fill one and
    > press the submit link button, it won't be able to submit because the other
    > field would be empty.
    > Which is annoying.
    >
    > Is there a way to limit the scope of the required field validator?
    > I coukld just remove it, but it provide nice features, so I'm wondering if
    > there is a solution to this problem, I have heard that ASP.NET 2.0 solve
    > it...
    >
     
    Peter Blum, Feb 23, 2006
    #4
  5. Lloyd Dupont

    Lloyd Dupont Guest

    Hi Peter,

    Thanks for your links.
    Anyway I'm using 2.0 and it's an home project so.. I will certainly go with
    build in validation group in 2.0


    "Peter Blum" <> wrote in message
    news:...
    > Hi Lloyd,
    >
    > There are a couple of solutions for ASP.NET 1.1:
    >
    > 1. Use server side validation when the page is submitted to fire the
    > Validate() method of only the desired validators. This article -
    > http://aspalliance.com/699 - shows you how (along with many other
    > validation questions). See the topic "Several buttons associated with
    > their own validators".
    >
    > 2. I built a replacement to the ASP.NET validators that fixes the many
    > limitations I've found. Its called "Professional Validation And More" (
    > http://www.peterblum.com/vam/home.aspx ). My validators have validation
    > groups. You simply assign a group name to the Group property on the submit
    > button and the associated validators. There are an enormous number of
    > other improvements I've made to validation and I include a utility to
    > quickly convert a page from your existing validators to mine.
    >
    > --- Peter Blum
    > www.PeterBlum.com
    > Email:
    > Creator of "Professional Validation And More" at
    > http://www.peterblum.com/vam/home.aspx
    >
    > "Lloyd Dupont" <net.galador@ld> wrote in message
    > news:...
    >> On my page the user is ask to set of question.
    >> Say there I have 2 controls like that
    >> == pseudo-C#-code for my control ==
    >> class MyControl : CompositeControl
    >> {
    >> TextBox text;
    >> LinkButton button
    >>
    >> override void CreateChildControl()
    >> {
    >> text = new TextBox();
    >> text.ID = "text"
    >> Controls.Add(text);
    >>
    >> button = new LinkButton();
    >> buton.Text = submit;
    >> button.Click = HCSubmit;
    >> button.ID = "submit";
    >>
    >> // == problem here
    >> RequieredFieldValidator rfv = new RequiredFieldValidator();
    >> rfv.ControlToVerify = "text";
    >> Control.Add(rfv);
    >> }
    >> }
    >> As you could see, text should have some value in it.
    >> Now let's say I have 2 such control on the page and the user fill one and
    >> press the submit link button, it won't be able to submit because the
    >> other field would be empty.
    >> Which is annoying.
    >>
    >> Is there a way to limit the scope of the required field validator?
    >> I coukld just remove it, but it provide nice features, so I'm wondering
    >> if there is a solution to this problem, I have heard that ASP.NET 2.0
    >> solve it...
    >>

    >
    >
     
    Lloyd Dupont, Feb 23, 2006
    #5
  6. Lloyd Dupont

    Lloyd Dupont Guest

    As anyone was able to provide the (simple) answer let it be know it is very
    simple.
    BaseValidator and submiting control (LinkButton, Button, etc...) have a
    string ValidationGroup { get; set;}
    property.
    Just fill it and... Voila!

    --
    Regards,
    Lloyd Dupont

    NovaMind development team
    NovaMind Software
    Mind Mapping Software
    <www.nova-mind.com>
    "Lloyd Dupont" <net.galador@ld> wrote in message
    news:...
    > On my page the user is ask to set of question.
    > Say there I have 2 controls like that
    > == pseudo-C#-code for my control ==
    > class MyControl : CompositeControl
    > {
    > TextBox text;
    > LinkButton button
    >
    > override void CreateChildControl()
    > {
    > text = new TextBox();
    > text.ID = "text"
    > Controls.Add(text);
    >
    > button = new LinkButton();
    > buton.Text = submit;
    > button.Click = HCSubmit;
    > button.ID = "submit";
    >
    > // == problem here
    > RequieredFieldValidator rfv = new RequiredFieldValidator();
    > rfv.ControlToVerify = "text";
    > Control.Add(rfv);
    > }
    > }
    > As you could see, text should have some value in it.
    > Now let's say I have 2 such control on the page and the user fill one and
    > press the submit link button, it won't be able to submit because the other
    > field would be empty.
    > Which is annoying.
    >
    > Is there a way to limit the scope of the required field validator?
    > I coukld just remove it, but it provide nice features, so I'm wondering if
    > there is a solution to this problem, I have heard that ASP.NET 2.0 solve
    > it...
    >
     
    Lloyd Dupont, Feb 27, 2006
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    3
    Views:
    1,191
    bruce barker
    Feb 25, 2004
  2. Danny Anderson
    Replies:
    10
    Views:
    519
    Niklas Borson
    Oct 14, 2003
  3. Akaketwa
    Replies:
    1
    Views:
    5,060
    impaler
    Sep 22, 2006
  4. Replies:
    0
    Views:
    572
  5. Learner

    Need help on validation on a group of controls

    Learner, Jun 8, 2006, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    154
    Learner
    Jun 14, 2006
Loading...

Share This Page