Validate over several Web User Controls

M

Moistly

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
 
S

seigo

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
 
M

Moistly

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top