Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
protected void Page_Load(object sender, EventArgs e)
{        
    TextBox tb = (TextBox)Master.FindControl("txtEmployee_code");
}
 
set the properties in master page. call this properties another page, but not working
 
public TextBox tb
{
get { return txtEmployee_code; }
set { txtEmployee_code = value; }
}
Posted 31-May-12 2:14am
20119991.2K
Edited 31-May-12 6:43am
v4
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 4

You can do it like this
 
^]
 
Replace LinkButton to TextBox
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

try TextBox tb = (TextBox)Page.FindControl("txtEmployee_code");
  Permalink  
Comments
2011999 at 31-May-12 12:27pm
   
Not Working
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

My first guess would be that your control is not actually on the master page but on a nested page. If so, this won't find it. You would need to do something like:
this.Form.FindControl("txtEmployee_code");
 
You can find more examples and more ideas here (make sure to look at the comments, since they have other options people have tried):
^]
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

1. Check whether you have added the mastertype declaration in the page directive.
2. if you want to use set/get the textbox value then instead of doing a findcontrol define a public property in the masterpage for setting and getting it and then call this property from the page.
  Permalink  
Comments
Ehsan yazdani rad at 11-Aug-13 14:58pm
   
Part 2 is Solution but is not description for problem. Why FindControl not working?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 6,725
1 OriginalGriff 6,696
2 CPallini 5,315
3 George Jonsson 3,589
4 Gihan Liyanage 2,650


Advertise | Privacy | Mobile
Web04 | 2.8.140922.1 | Last Updated 31 May 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100