Validate over several Web User Controls

Discussion in 'ASP .Net' started by Moistly, Aug 17, 2007.

  1. Moistly

    Moistly Guest

    Hi everyone,

    This is a scenerio for my problem,

    I have one aspx page with several instances of the same Web User
    Control (ascx files).

    I have for example the Web User Control that has a textbox that
    requires a numeric value (I am using the RequiredField, and
    RangeValidator here with no problems)

    What I also need to validate, is that 1 (and only 1) instance of the
    Web User Control is given a textbox value > 0, while all the others
    must be == 0.

    Any advice?
    Thanks
    Moistly, Aug 17, 2007
    #1
    1. Advertising

  2. Moistly

    seigo Guest

    On Aug 17, 5:28 pm, Moistly <> wrote:
    > Hi everyone,
    >
    > This is a scenerio for my problem,
    >
    > I have one aspx page with several instances of the same Web User
    > Control (ascx files).
    >
    > I have for example the Web User Control that has a textbox that
    > requires a numeric value (I am using the RequiredField, and
    > RangeValidator here with no problems)
    >
    > What I also need to validate, is that 1 (and only 1) instance of the
    > Web User Control is given a textbox value > 0, while all the others
    > must be == 0.
    >
    > Any advice?
    > Thanks


    Hi Moistly,

    I think that you should do the following:

    1) add a public property for web user control that will contain the
    value of textbox:

    public int Value
    {
    get { return Convert.ToInt32(TextBox1.Text); }
    }

    2) add CustomValidator to page where you placed a few instances of web
    user controls. In CustomControl function check Value of all web user
    controls and if only one has Value > 0 then return true in other way -
    false.

    Regards,
    Alexander Kleshchevnikov.
    MCP
    www.klalex.com
    seigo, Aug 17, 2007
    #2
    1. Advertising

  3. Moistly

    Moistly Guest

    On Aug 17, 4:25 pm, seigo <> wrote:
    > On Aug 17, 5:28 pm, Moistly <> wrote:
    >
    >
    >
    > > Hi everyone,

    >
    > > This is a scenerio for my problem,

    >
    > > I have one aspx page with several instances of the same Web User
    > > Control (ascx files).

    >
    > > I have for example the Web User Control that has a textbox that
    > > requires a numeric value (I am using the RequiredField, and
    > > RangeValidator here with no problems)

    >
    > > What I also need to validate, is that 1 (and only 1) instance of the
    > > Web User Control is given a textbox value > 0, while all the others
    > > must be == 0.

    >
    > > Any advice?
    > > Thanks

    >
    > Hi Moistly,
    >
    > I think that you should do the following:
    >
    > 1) add a public property for web user control that will contain the
    > value of textbox:
    >
    > public int Value
    > {
    > get { return Convert.ToInt32(TextBox1.Text); }
    >
    > }
    >
    > 2) add CustomValidator to page where you placed a few instances of web
    > user controls. In CustomControl function check Value of all web user
    > controls and if only one has Value > 0 then return true in other way -
    > false.
    >
    > Regards,
    > Alexander Kleshchevnikov.
    > MCPwww.klalex.com


    Thanks alot, that does indeed work.
    Moistly, Aug 20, 2007
    #3
    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. Axel Dahmen
    Replies:
    1
    Views:
    461
    Teemu Keiski
    Nov 12, 2003
  2. Dominik Kaspar

    writing code over several lines

    Dominik Kaspar, Oct 17, 2003, in forum: Python
    Replies:
    20
    Views:
    595
    Peter Hansen
    Oct 21, 2003
  3. Martin DeMello

    serial iteration over several lists

    Martin DeMello, Aug 21, 2004, in forum: Python
    Replies:
    4
    Views:
    282
    Martin DeMello
    Aug 23, 2004
  4. thadpeiffer

    User Control not in available controls to validate

    thadpeiffer, Oct 6, 2004, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    89
    thadpeiffer
    Oct 6, 2004
  5. Victor \Zverok\ Shepelev

    RDOC: several related modules in several C files

    Victor \Zverok\ Shepelev, Mar 6, 2007, in forum: Ruby
    Replies:
    3
    Views:
    169
    Max Lapshin
    Mar 16, 2007
Loading...

Share This Page