Link to home
Start Free TrialLog in
Avatar of JRockFL
JRockFLFlag for United States of America

asked on

Programmatically set label value in web user control

I have a web user control customers.ascx that has one lablel lblFirstName.

I have default.aspx and I register that web user control.

How can I set the value of the label programmatically?



Avatar of JRockFL
JRockFL
Flag of United States of America image

ASKER

I came up with this solution...any thoughts?

============================
User Control
============================
public partial class customers : System.Web.UI.UserControl
{
    private static string _firstName;

    protected void Page_Load(object sender, EventArgs e)
    {
        lblFirstName.Text = _firstName;
    }

    public void SetFirstName(string firstName)
    {
        _firstName = firstName;
    }
   
}

==========================
ASP.NET Page
==========================
    protected void Page_Load(object sender, EventArgs e)
    {
        customers cs = new customers();
        cs.SetFirstName("Jason");  
    }
ASKER CERTIFIED SOLUTION
Avatar of tusharashah
tusharashah

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial