dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersAsheej T K
Matt M
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Forums » .NET » ASP.NET »

How to Access Page value in to User Control?


Posted Date: 06 Jul 2012      Posted By:: Manoj Savalia     Member Level: Silver    Member Rank: 776     Points: 2   Responses: 1



Hi,
I have one user control and one page. In my aspx page i add user control. I want to access page value into my user control.
Ho can i access page value in user control??




Responses

#679319    Author: Ajatshatru Upadhyay      Member Level: Gold      Member Rank: 19     Date: 08/Jul/2012   Rating: 2 out of 52 out of 5     Points: 4

Hi,

You can access the aspx page's controls from within the user control added to that aspx page.
Below is an example:

Let us assume that in the aspx page, we have a Label control having ID as "Label1". You can access this label control from user controls as:

The user control's code behind:


protected void Page_Load(object sender, EventArgs e)
{
Label lbl = (Label)this.Parent.FindControl("Label1");
if (lbl != null)
{
lbl.Text = "Text from User control";
}
}


Hope it'll help you.
Regards
Ajatshatru



 
Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.



Next : Adding check box in header row of grid view
Previous : Autocomplete Extender
Return to Discussion Forum
Post New Message
Category:

Related Messages



Follow us on Twitter: https://twitter.com/dotnetspider

Active Members
TodayLast 7 Daysmore...

Awards & Gifts
Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.