473,396 Members | 2,013 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.

Accessing an HTML element from a child control

I have a page structured as such:

page.aspx
<title>
control1.ascx
control2.ascx

The page, may or may not have a title tag. If it doesn't, control1 writes it
out.

I'd like to be able to manipulate the text in the TITLE tag from control2.
Is that possible? If so, what would be the logic behind it? I asked a
similiar question before, and it was suggested that I set the TITLE tag to
"runat=server" and then declare it in my codebehind. The catch is that
control2 won't know if the title is in the parent page or control1, so I'm
not sure how to address it.

-Darrel
Nov 18 '05 #1
1 1128
Hi,

A very dirty solution:

Add a literal in the page (<asp:literal id="literalSetTitle"
runat="server"/>). Then in the controls:

[C#]
Literal literalSetTitle = Page.FindControl("literalSetTitle") as Literal;
if(literalSetTitle != null)
literalSetTitle.Text = string.Format(
@"<script>document.title='{0}';</script>",
"New Title")

And replace "New Title" with the one you need. Note that the last control to
execute this code will set the title.

Hope this helps
Martin
"darrel" <no*****@hotmail.com> wrote in message
news:OW**************@TK2MSFTNGP11.phx.gbl...
I have a page structured as such:

page.aspx
<title>
control1.ascx
control2.ascx

The page, may or may not have a title tag. If it doesn't, control1 writes it out.

I'd like to be able to manipulate the text in the TITLE tag from control2.
Is that possible? If so, what would be the logic behind it? I asked a
similiar question before, and it was suggested that I set the TITLE tag to
"runat=server" and then declare it in my codebehind. The catch is that
control2 won't know if the title is in the parent page or control1, so I'm
not sure how to address it.

-Darrel

Nov 18 '05 #2

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

Similar topics

8
by: [RaZoR] | last post by:
hello, main script creates IE window, put an array there and then calls a child script. chils script makes an array element equal to some object and returns control to main script. then main...
1
by: BGMeshi | last post by:
Hi, The following javascript code (serving a main HTML page) dynamically creates IFRAME to contain other HTML page. Everyting works OK, however when I am trying to access the main HTML page...
3
by: Christopher Benson-Manica | last post by:
I have an HTMLInputElement in a <td>. I want to access all the <td>'s in the same row as the input element. var tr=theInputElement.parentNode.parentNode; Why isn't the input element's...
6
by: Chris Styles | last post by:
Dear All, I've been using some code to verify form data quite happily, but i've recently changed the way my form is structured, and I can't get it to work now. Originally : The form is...
4
by: John Holmes | last post by:
I'm using data to rename some web controls on a form that uses a repeater contol and so it can have mulitple instances of the same control set. The controls get renamed (thanks to Steven Cheng's...
4
by: Sathyaish | last post by:
I am no JavaScript progammer, and unfortunately am having to babysit an old code base that has a lot of JavaScript in it. I have two questions: (1) Can two HTML controls have the same name? It...
1
by: Jeff Lynch | last post by:
I'd like to add the following attributes to the Login control's Login Button to create a CSS rollover effect. How can I access the control's login button from the page's code-behind? ...
1
by: adamredwards | last post by:
I have a page with some form elements that are dynamically generated. They are inserted into the dom by first cloning a node, changing the values like name, and then inserted with insertBefore(). ...
4
by: SteveT | last post by:
I am wanting to populate several treeviews, one for the <TRs> group and one for the <TGsgroup. Is there a simplier way to populate the Treeview than the one I did below? It seems difficult to...
1
by: ludwiga | last post by:
Hi all, I am trying to validate my first web site and most of the common errors that i am getting are the following!!! I am sure you can help me thanks in advance. <!DOCTYPE HTML PUBLIC...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.