user831055
user831055

Reputation:

usercontrol in a placeholder

I've tried doing the following:

        var userControl = UserControls.ProductDetailUserControl();
        userControl.ID = "id_SubProduct_"+productId;
        userControl.Visible = true;
        userControl.ValidationDependentOnControl = productOption.ClientID;
        userControl.ConditionallyVisible = productOption;
        plhDetails.Controls.Add(userControl);

throws a null exception

Upvotes: 3

Views: 108

Answers (1)

Nickz
Nickz

Reputation: 1880

Try this

 var uProductDetails = (UserControls.ProductDetailUserControl)Page.LoadControl("UserControls/ProductDetailUserControl.ascx");

    //set properties     
    plhDetails.Controls.Add(userControl);   

Upvotes: 3

Related Questions