PC Review


Reply
Thread Tools Rate Thread

Calling methods in the Master Page advice

 
 
Spondishy
Guest
Posts: n/a
 
      24th Aug 2006
Hi,

I have a master page with a literal control. As an example, I'm trying
to set the text of the literal to the current time. In the code behind
for the master page I've got a method that returns the string for the
current time.

So I have this:

<asp:Literal ID="Literal1" runat="server"
Text="<%#GetTime()%>"></asp:Literal>

Unfortunately, this doesn't appear to work in a master page. Any way of
doing this?

 
Reply With Quote
 
 
 
 
clintonG
Guest
Posts: n/a
 
      24th Aug 2006
// When the control is in the Master
Literal lit = (Literal)Master.FindControl("Literal1");
lit.Text = DateTime.Now( );

// When the control is in a content page we have to use trace to locate the
control in the control hierarchy and use FindControl on each object.

Go to OdeToCode.com there are a series of excellent articles about
MasterPages.

<%= Clinton Gallagher
NET csgallagher AT metromilwaukee.com
URL http://clintongallagher.metromilwaukee.com/
MAP 43°2'17"N 88°2'37"W : 43°2'17"N 88°2'37"W


"Spondishy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
>
> I have a master page with a literal control. As an example, I'm trying
> to set the text of the literal to the current time. In the code behind
> for the master page I've got a method that returns the string for the
> current time.
>
> So I have this:
>
> <asp:Literal ID="Literal1" runat="server"
> Text="<%#GetTime()%>"></asp:Literal>
>
> Unfortunately, this doesn't appear to work in a master page. Any way of
> doing this?
>



 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calling usercontrol methods in master page from content page Chevron Boyde Microsoft ASP .NET 1 8th Dec 2008 03:18 PM
accessing the master page's methods.. Ned White Microsoft ASP .NET 1 12th May 2008 02:19 AM
Calling Master Page methods directly from Content Page inline code(.aspx file) DevNll2002@gmail.com Microsoft ASP .NET 1 9th Apr 2008 01:51 AM
Repost: Design advice needed: loading a DLL and calling the methods in it Nick Malik Microsoft Dot NET 4 10th Aug 2004 02:46 PM
Design advice needed: loading a DLL and calling the methods in it Nick Malik Microsoft C# .NET 5 10th Aug 2004 02:46 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:20 PM.