|
|
|
start date: Fri, 17 Aug 2007 07:28:06 -0700,
posted on: microsoft.public.dotnet.framework.aspnet
back
| Thread Index |
|
1
Moistly
|
|
2
seigo
|
|
3
Moistly
|
Validate over several Web User Controls
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
Date:Fri, 17 Aug 2007 07:28:06 -0700
Author:
|
Re: Validate over several Web User Controls
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
Date:Fri, 17 Aug 2007 08:25:56 -0700
Author:
|
Re: Validate over several Web User Controls
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.
Date:Mon, 20 Aug 2007 08:01:29 -0000
Author:
|
|
|