gjshah7254
7/9/2014 - 11:58 PM

Pass Variables / Parameters to user control

Pass Variables / Parameters to user control

//Main File with User control in it

<%@ Register TagName="Header" TagPrefix="uc" Src="~/usercontrolfile.ascx"%>
<uc:Header id="ucControlName" runat="server" EnableViewState="false" Paramater1="PassValue"/>

//Or you can pass from the Code Behind for main file
ucControlName.Paramater1 = "PassValue";

//User Control file
public string GetParamater1 = "";

public string Paramater1
    {
        set { GetParamater1 = value; }
        get { return GetParamater1; }
    }
    
//Now you can use "GetName" anywhere...