jittu
jittu

Reputation: 25

I want to pass value from aspx.cs page to master page

I have a master page in that page i want to show the user name in a label . but i want to pass the value on that label from .cs page. My page is also connected to the master page. please help me how can i do that.

Upvotes: 1

Views: 178

Answers (2)

Yahya Hussaini
Yahya Hussaini

Reputation: 88

You can use Sessions... Session["Session Name"]= someValues; You can assign a value to session and show it on master page with the help of textbox or lbl etc

Upvotes: 0

Anoop H.N
Anoop H.N

Reputation: 1264

You can try with the below code in your content page.aspx.cs.

protected void Page_Load(object sender, EventArgs e)
{
     Label lblMasterPage= this.Master.FindControl("lblMasterPage") as Label;
     lblMasterPage.Text = "Setting Label from Content Page";
}

Note : use your master page label id instead of lblMasterPage.

Hope this helps!

Upvotes: 1

Related Questions