PC Review


Reply
Thread Tools Rate Thread

append child

 
 
josh
Guest
Posts: n/a
 
      5th Sep 2008
Hi,

I wish to know if there is a way to have for ex.

<head>
<title>xxx</title>
</head>

a way to take the <title> (getElementsByTagName()...) and
then to use a sintax like appendChild to append some <script> to
<head>

I view that if I use head.innerHTML then all the content into <head>
is overwritten!

Thanks

P.S.
FindControl give me the way only to take web controls that have an ID
but how to take controls or
HTML tag that does not have that ID?

Thanks
 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      5th Sep 2008
Provided the page is an ASP.NET page, you can get the title without the
kludge, as it is exposed.

string title = Page.Header.Title;

You can then do what you want with it. Unless your JavaScript absolutely has
to be in the <head> region, you should consider one of the registration
commands for JavaScript (RegisterStartUpScript or RegisterClientSideScript),
as they will automatically place the script at the top or where it is used.
This is found in the ClientScriptManager class.

If you absolutely must add to the head section, you can do something like
this:

Page.Header.Controls.Add(ctl);

As an example:

HtmlGenericControl ctl = new HtmlGenericControl("script");
ctl.Attributes.Add("type", "text/javascript");
ctl.InnerHtml = "alert('Page name = " + Page.Header.Title + "');";
Page.Header.Controls.Add(ctl);

You can also use a literal control in the same manner, but you will have to
write out the tags as well.


--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

Subscribe to my blog
http://feeds.feedburner.com/GregoryBeamer#

or just read it:
http://feeds.feedburner.com/GregoryBeamer

********************************************
| Think outside the box! |
********************************************
"josh" <(E-Mail Removed)> wrote in message
news:5721db33-d77b-4f0d-84b0-(E-Mail Removed)...
> Hi,
>
> I wish to know if there is a way to have for ex.
>
> <head>
> <title>xxx</title>
> </head>
>
> a way to take the <title> (getElementsByTagName()...) and
> then to use a sintax like appendChild to append some <script> to
> <head>
>
> I view that if I use head.innerHTML then all the content into <head>
> is overwritten!
>
> Thanks
>
> P.S.
> FindControl give me the way only to take web controls that have an ID
> but how to take controls or
> HTML tag that does not have that ID?
>
> Thanks


 
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
Append master table and update child at same time? Darin Microsoft Access Queries 0 6th Apr 2006 06:57 PM
Append Child Nodes XML in Memory =?Utf-8?B?ZnJlbWVudXN1bA==?= Microsoft Dot NET 7 15th Mar 2005 02:37 PM
Append XML Child Node (Additional problems) =?Utf-8?B?ZnJlbWVudXN1bA==?= Microsoft Dot NET 2 14th Mar 2005 06:39 PM
append child records pcurran Microsoft Access Queries 0 21st Feb 2004 01:07 PM
append child records pcurran Microsoft Access Queries 0 21st Feb 2004 01:07 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:51 PM.