Parent String on Web User Control

M

Msdn

I have a web usercontrol which contains a Text box and a Custom Validation
Control

On a page i have a Public String ErrStr

When i perform validation i would like to add the validation result to the
Public String ErrStr on my parent page.

How do i do that ?

Regards Keld Jakobsen
 
P

Prakash V

Hi,
u place a Property in the User control and get the Errormessage
from the property in the page.

Regards,
Prakash.V
 
M

Msdn

Ok, but i did it in another way which seems to work fine
If (Trim(args.Value) = "") Then
args.IsValid = False
Dim CurrentPage As Page = Parent.Page
Dim ErrorProperty As System.Reflection.PropertyInfo
Dim ErrorPropertyType As System.Type = CurrentPage.GetType
ErrorProperty = ErrorPropertyType.GetProperty("ErrStr")
ErrorProperty.SetValue(CurrentPage, ControlError, Nothing)
Else
args.IsValid = True
End If

Regards Keld Jakobsen
 
M

MasterGaurav

A very long way...

How about just doing it like this:

class MyUserControl
{
public IValidator Validator { get { ... } set { ... } }
public string ErrorMessage
{
get
{
if(Validator != null && !Validator.IsValid)
return Validator.ErrorMessage;
return string.Empty; // or null, whatever you want to return.
}
 

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

No members online now.

Forum statistics

Threads
473,951
Messages
2,570,113
Members
46,699
Latest member
Abigail89S

Latest Threads

Top