473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Calling methods in the Master Page advice

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?

Aug 24 '06 #1
1 834
// 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" <sp*******@tiscali.co.ukwrote in message
news:11**********************@p79g2000cwp.googlegr oups.com...
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?

Aug 24 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Don Wash | last post by:
Hi All! I'm developing ASP.NET pages using VB.NET language. My background is VB6 and ASP3. Right now, I'm evaluating strategies on creating reusable and common functions and methods for ASP.NET....
6
by: Don Wash | last post by:
Hi All! I'm developing ASP.NET pages using VB.NET language. My background is VB6 and ASP3. Right now, I'm evaluating strategies on creating reusable and common functions and methods for ASP.NET....
9
by: J055 | last post by:
Hi I have a standard asp page which uses a MasterPage. The MasterPage contains a User control. How can I access a public method in the User control from my WebForm page? I can't move the method...
1
by: DevNll2002 | last post by:
Can it be done? ( This is a related issue to my recent post... http://groups.google.com/group/microsoft.public.dotnet.framework.aspnet/browse_thread/thread/a229a66642bedfaf/870614ae257ae699...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.