473,608 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Register Client Script

Goh
Hi,

May I know how to register a java script inside the <head> tag not the
body? I found only got method that able register at the body like
RegisterStartup Script and RegisterClientS criptBlock.
I would like to register this script inside user control. and this
script must be run when the page is load.
Got any method that able to call to solve this problem?
Thanks in advance/
Dec 4 '05 #1
3 2276

There isn't a way to do this directly. Why do you want to do this? ASP.NET
puts the code inside of the Form tag so that's in the scope of the page
logic and so that it can run Onload code easily.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com
www.west-wind.com/weblog
"Goh" <go*@noemail.no email> wrote in message
news:OC******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

May I know how to register a java script inside the <head> tag not the
body? I found only got method that able register at the body like
RegisterStartup Script and RegisterClientS criptBlock.
I would like to register this script inside user control. and this
script must be run when the page is load.
Got any method that able to call to solve this problem?
Thanks in advance/

Dec 4 '05 #2
You should be able to do this by creating a "runat=serv er" head tag in your
page, and supplying an HtmlGenericCont rol in the CodeBehind to work with it
programmaticall y. The InnerHtml property can then be used to add a block of
JavaScript to the contents of the Control. Alternatively, you could add a
LiteralControl containing the JavaScript to the Controls Collection of the
Control.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
You can lead a fish to a bicycle,
but you can't make it stink.

"Goh" <go*@noemail.no email> wrote in message
news:OC******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

May I know how to register a java script inside the <head> tag not the
body? I found only got method that able register at the body like
RegisterStartup Script and RegisterClientS criptBlock.
I would like to register this script inside user control. and this
script must be run when the page is load.
Got any method that able to call to solve this problem?
Thanks in advance/

Dec 4 '05 #3
Yes, i wonder'd myself about MS code being placed inside the BODY tags.

Your explaination makes it clear, in fact it's i find this logical because
it's modular this way.
If you ever add another form to the html code, there could be specific JS
code for that form only.
(I am not saying these are nested functions, unique names might still be
required. :) )

"Rick Strahl [MVP]" <ri********@hot mail.com> schreef in bericht
news:%2******** **********@tk2m sftngp13.phx.gb l...

There isn't a way to do this directly. Why do you want to do this? ASP.NET
puts the code inside of the Form tag so that's in the scope of the page
logic and so that it can run Onload code easily.

+++ Rick ---

--

Rick Strahl
West Wind Technologies
www.west-wind.com
www.west-wind.com/weblog
"Goh" <go*@noemail.no email> wrote in message
news:OC******** ********@tk2msf tngp13.phx.gbl. ..
Hi,

May I know how to register a java script inside the <head> tag not
the body? I found only got method that able register at the body like
RegisterStartup Script and RegisterClientS criptBlock.
I would like to register this script inside user control. and this
script must be run when the page is load.
Got any method that able to call to solve this problem?
Thanks in advance/


Dec 4 '05 #4

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

Similar topics

6
1466
by: use dmgass at hotmail dot com | last post by:
I'm writing a module and when it is imported by a script I want some code automatically executed when the importing script is finished executing. I'd like it to execute before interactive mode is entered when executing the importing script from the command line. I don't want to have to impose that the importing script must call a function at it's end. Any help is greatly appreciated!!
1
14135
by: G Kannan | last post by:
Hey all! I have written a perl script to retrieve information from a HTML Form and insert the data into an Oracle database table. I am gettting the the following error message: "Use of uninitialized value in concatenation (.) at register.pl line 38, <STDIN> line 10." The PERL code is as follows:
1
1752
by: Darren Clark | last post by:
How does everyone register and access input objects on the client side? well... i suppose i am after some alternate ways... i use the following code to put the neccessary client javascript code so that i can then use them later... private void RegisterClientObjects() { System.Text.StringBuilder sBuild = new System.Text.StringBuilder();
3
7747
by: Hardy Wang | last post by:
Hi, By calling Page.RegisterClientScriptBlock, the JavaScript will be generated right after VIEWSTATE hidden field. Is there a way I can register my script to end of page instead beginning? -- WWW: http://hardywang.1accesshost.com ICQ: 3359839 yours Hardy
0
1047
by: Stuart Shay | last post by:
Hello All: I am having problem with the getting the Follow JS to run on Startup, the Script gets the client UTC Offset Time it seems the script seems to post back private string GetClientUTCOffsetScript() { string scriptGetClientUTCOffset = "<scriptlanguage=javascript>" + "var now = new Date();" +
2
6305
by: SimonZ | last post by:
I have function in my app_code folder. Is it possible to register client script block from app_code function? public static void CheckSessionModal() { String scriptValue="";
1
2131
by: lourivas | last post by:
Hi, I create a class with a property called MyProperty that needs to register a client script if the value is set to true. When i change the property value to true i always receive a message "Property value is not valid/Object reference not set to an instance of an object". I'm using VS 2005. What i'm missing? see:
1
2634
by: Gen | last post by:
Hello there, I am a leader of a team, developing business application based on the ASP.NET platform. Now we need to add cash register support to the application and it seems to be a bit of a problem. In general communication with the cash register consists of two steps: 1 - Creation of a text file, describing the items, quantities and prices; 2 - Invoke cash register's driver (which is an exe file in most cases), passing the text file...
3
7881
by: dixonjm | last post by:
Hi, In my page load event i have:- RegisterClientScripts(); if (!Page.IsClientScriptBlockRegistered("BannerScript")) if (!IsPostBack) { _userLink.Attributes.Add("onclick", string.Format("ShowPopupWindow('UserWindow');")); }
0
8069
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8503
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8488
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8358
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6017
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3972
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4036
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2479
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1339
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.