Wednesday, 27 June 2012

how to open user control in asp.net

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class _Default : System.Web.UI.Page
{
    UserControl uc = new UserControl();
    UserControl uc1 = new UserControl();
    protected void Page_Load(object sender, EventArgs e)
    {
       
        uc=(UserControl)LoadControl("WebUserControl.ascx");
        uc1 = (UserControl)LoadControl("WebUserControl2.ascx");
    }
    protected void lb_Click(object sender, EventArgs e)
    {
        pn.Controls.Add(uc);
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        pn.Controls.Add(uc1);
    }
}

No comments:

Post a Comment