I want to value master page Label value on Content page . [Resolved]

Posted by Prabhakar under Regular Expressions on 5/27/2011 | Points: 10 | Views : 7264 | Status : [Member] [MVP] | Replies : 11
Hi experts. .

i have one label on master page .. i want to retrive value in content page how'z possible . .

i am try some this it's not working . .
string mpLabel = ((Label) Master.FindControl("lblfrom")).Text;
say suggestion

Best Regard's
Prabhakar



Responses

Posted by: Ndebata on: 5/27/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi
Just try to add a property in master page that will expose the label.text
lets say the ID of label in master page is lblinMaster
public String LabelValue

{
get { return lblinMaster.Text; }
}

Then add a refernece to your master in the content page where you are using the master.
<%@ MasterType VirtualPath="~/MasterPage.master" %>

Then in content page you can access
Master.LabelValue

Thanks,
Debata

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/27/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi
Please find the attached code and check it against yours, its working.

Thanks,
Debata
 Download source file

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 5/27/2011 [Member] Starter | Points: 25

Up
0
Down
refer the below link

http://www.eggheadcafe.com/tutorials/aspnet/969a11b2-a5a4-4a51-852a-003fd40bbd68/access-master-page-control-from-content-page.aspx

Thanks&Regards
LakshmiNarayana Nalluri.

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bugwee on: 5/27/2011 [Member] Starter | Points: 25

Up
0
Down
hello Sir,

I have found this link. Hope this may help.
http://www.4guysfromrolla.com/articles/013107-1.aspx#postadlink

Regards,
Bugwee

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 5/27/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Ndebata


thanku fro responding . . but u write code but i write in child page for fetch it value


Best Regard's
Prabhakar

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/27/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Prabhakar,
In the content page you can use Master.LabelValue.
Child page is same as content page in my post (Modified the English :) ).
Thanks,
Debata

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bugwee on: 5/27/2011 [Member] Starter | Points: 25

Up
0
Down
Hi

I think what you want is somewhat like this. But in here what i am retrieving is textbox value.
http://www.dotnetfunda.com/forums/thread4543-get-and-post-method-using-masterpage.aspx

Regards,
Bugwee

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 5/27/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
hi ndebata

i am use like this . .


string ram = Master.LabelValue.ToString();

my label on master page fill but on content page he return null value


Best Regard's
Prabhakar

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Prabhakar on: 5/27/2011 [Member] [MVP] Starter | Points: 25

Up
0
Down
Hi Ndebata

thanku for code . . it's working fine . . i am little bit confuse . but now i slove it . . i am using cookies . .

it's working

   public string LabelValueimgssnofrom

{
get { return HttpContext.Current.Request.Cookies["imgssnofrom"].Value.ToString(); }
}


Best Regard's
Prabhakar

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 5/27/2011 [Member] Starter | Points: 25

Up
0
Down
But Cookies may not be good in some context like browser can refuse cookies. :)
Thanks,
Debata

Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nandakumar531 on: 5/31/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Prabhakr,

Assign value to label in Master Page Page_Init event instead of Page_Load Event
y bcz u are accessing Master Page Label value before firing page_load event of the MasterPage.

the u access when ever u want the the Master page Label in ur code

Master Page

protected void Page_Init(object sender, EventArgs e)
{
LabelValue="xyz";
}

public string LabelValue
{
get { return this.lblfrom.Text; }
set { this.lblfrom.Text = value; }
}


Other Page abcd.aspx
string mpLabel = ((Label) Master.FindControl("lblfrom")).Text; 



it works for me ..!


Prabhakar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response