ASP.Net master page and content page
I have a login screen in the content page ,Aftre login the values should go to the Master page on the Label.
please give some solution

Recommended Answers

Session
Cookies
Singleton object
Store in database for retrieval
On page load get the MasterPage object and use FindControls

Any of those should be able to do it.

This may also help you: http://msdn.microsoft.com/en-us/library/dct97kc3(v=vs.100).aspx

Jump to Post

All 4 Replies

Member Avatar

Session
Cookies
Singleton object
Store in database for retrieval
On page load get the MasterPage object and use FindControls

Any of those should be able to do it.

This may also help you: http://msdn.microsoft.com/en-us/library/dct97kc3(v=vs.100).aspx

You can call the contentpage value in the masterpage as follows:

        Label lb = (Label)ContentPlaceHolder1.FindControl("label1");
        TextBox1.Text=lb.Text;

Where label1 is the label in the content page and textbox1 is a textbox in the masterpage...

http://www.odetocode.com/Articles/450.aspx

Create an instance of the Master page, find the control on master page and do what you need to do ... don't make it overy complicated.

In the example below I have a label on the master page called "lblMasterPageLabel".
In the content page that is referencing the master page I can write to that label like this:

        MasterPage mp = new MasterPage();
        mp = Master;

        Label lb = (Label)mp.FindControl("lblMasterPageLabel");
        lb.Text = "Found It";`
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.