What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 11551 |  Welcome, Guest!   Register  Login
 Home > Forums > ASP.NET 4.0 > I want to value master page Label value on Content page . ...
Prabhakar

I want to value master page Label value on Content page .

Replies: 11 | Posted by: Prabhakar on 5/27/2011 | Category: ASP.NET 4.0 Forums | Views: 1843 | Status: [Member] [MVP] | Points: 10  


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


Reply | Reply with attachment | Alert Moderator

 Responses below this adGet hundreds of .NET Tips and Tricks videos

 Replies

Ndebata
Ndebata  
Posted on: 5/27/2011 3:24:57 AM
Level: Starter | Status: [Member] | Points: 50

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. | Reply | Alert Moderator 

Lakn2
Lakn2  
Posted on: 5/27/2011 3:31:37 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Bugwee
Bugwee  
Posted on: 5/27/2011 3:34:24 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Prabhakar
Prabhakar  
Posted on: 5/27/2011 3:35:09 AM
Level: Starter | Status: [Member] [MVP] | Points: 25

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. | Reply | Alert Moderator 

Ndebata
Ndebata  
Posted on: 5/27/2011 3:37:55 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Bugwee
Bugwee  
Posted on: 5/27/2011 3:40:11 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Prabhakar
Prabhakar  
Posted on: 5/27/2011 3:45:04 AM
Level: Starter | Status: [Member] [MVP] | Points: 25

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. | Reply | Alert Moderator 

Ndebata
Ndebata  
Posted on: 5/27/2011 3:56:03 AM  Download source file
Level: Starter | Status: [Member] | Points: 50

Resolved

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

Thanks,
Debata

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

Prabhakar
Prabhakar  
Posted on: 5/27/2011 4:11:02 AM
Level: Starter | Status: [Member] [MVP] | Points: 25

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. | Reply | Alert Moderator 

Ndebata
Ndebata  
Posted on: 5/27/2011 4:16:23 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Nandakumar531
Nandakumar531  
Posted on: 5/31/2012 9:11:55 AM
Level: Starter | Status: [Member] | Points: 25

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. | Reply | Alert Moderator 

Reply - Please login to reply


Click here to login & reply

Found interesting? Add this to:


 Latest Posts

Write New Post | More ...

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/24/2013 3:23:45 PM