FindControl from C# Class

  • Follow


I'm not sure if this is the correct approach or not. I'm trying to
create a class for Functions that are used on a regular basis. On
function will be to set the Text value that sits on the MasterPage.
How do I do this? I don't see Page or FindControl anywhere. Thanks
0
Reply Dave 2/3/2010 2:33:36 PM

"Dave" <Dave.Burkett@Jacobs.com> wrote in message 
news:23cf7e8d-4cd9-4d69-b9bd-309194be6f07@k2g2000pro.googlegroups.com...
> I'm not sure if this is the correct approach or not. I'm trying to
> create a class for Functions that are used on a regular basis. On
> function will be to set the Text value that sits on the MasterPage.
> How do I do this? I don't see Page or FindControl anywhere. Thanks

In your class file, import the namespace "System.Web". Then do the 
following:

Page myPage = (Page)HttpContext.Current.Handler;

This gives you a reference to the page that called the method in your class. 
From there, you can use the .Master property to get to the Master page, and 
either cast it to the type of your masterpage and directly access the 
control, or use FindControl on the Masterpage.

0
Reply Alberto 2/3/2010 4:00:44 PM


1 Replies
312 Views

(page loaded in 0.062 seconds)

Similiar Articles:











7/24/2012 12:49:11 AM


Reply: