tags:

views:

105

answers:

1

Hello,

I'm currently converting a set of .aspx pages and the VB code behind them to .ascx and C#.

I'm most of the way through the project now but have become a bit stuck as I'm fairly new to ASP.net.

Basically the system I'm working with validates a shopping basket but with me changing the class the code inherits from I'm having issues working out what I should change it too.

I'm changing from System.Web.UI.Page to System.Web.UI.UserControl and am primarily having problems with the Validator.Add(v) element of the code below:

public override void Validate()
{
    base.Validate();

    if (Profile.ShoppingCart == null || Profile.ShoppingCart.Items.Count == 0)
    {
        CustomValidator v = new CustomValidator();
        v.ErrorMessage = "You must have at least 1 course in your basket.";
        v.IsValid = false;
        Validator.Add(v);
    }
}

So if anyone could provide assitance it would be appreciated.

+2  A: 

Each user control contains a reference to the page that it is contained in.

Page.Validators.Add(v);
Jason Berkan