473,406 Members | 2,769 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,406 software developers and data experts.

Add jscript at the end (with ClientScript.RegisterClientScriptBlock) ?

Hi,
I need to place some javascript code at the end of my aspx page.
How can I do that using the ClientScript.RegisterClientScriptBlock ?

Thanks

Stan
Oct 6 '06 #1
3 2443
Hi,

Stan SR wrote:
Hi,
I need to place some javascript code at the end of my aspx page.
How can I do that using the ClientScript.RegisterClientScriptBlock ?

Thanks

Stan
AFAIK, you cannot specify the location of the script block using the
ClientScript manager.

If you want the script to be executed only when the page is fully
loaded, pack your code in a function, use ClientScript to register the
script, and add a "onload" event to the "body" tag, to execute the
function. The "onload" event is called when the whole page is parsed and
rendered.

If you have a reason to place the script at a specific place, you can
override the "Render" method in the Page class, and instead of calling
"base.Render( writer );", you render all the controls in the children
controls collection using the RenderControl method. When all the
controls have been rendered, add your script tag using the
HtmlTextWriter provided to the Render method.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 6 '06 #2
RegisterClientScript block renders the javascript after the <form>.
RegisterStartupScript renders before </form>.

-- bruce (sqlwork.com)

"Stan SR" <st**@pasdepam.netsunset.comwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Hi,
I need to place some javascript code at the end of my aspx page.
How can I do that using the ClientScript.RegisterClientScriptBlock ?

Thanks

Stan

Oct 6 '06 #3
Hi,

bruce barker (sqlwork.com) wrote:
RegisterClientScript block renders the javascript after the <form>.
RegisterStartupScript renders before </form>.

-- bruce (sqlwork.com)
Mmmh right. That makes more sense than my complicated proposal :-)

Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
Oct 6 '06 #4

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

Similar topics

6
by: PatLaf | last post by:
Hello to all I have created an asp.net application that needs to view pdf documents. I ran into a security issue but I added the identity impersonate = true and turned off anonymous access to the...
4
by: RFS666 | last post by:
Hello, I have the following problem: I have a web project where I display an activeX control that displays 2D-graphs on an aspx-page. I use jscript to access and modify the properties of the...
7
by: RFS666 | last post by:
Hello, I would like to use variables with a type in jscript.NET. I declare them as follows: var x : double = 5.03; This doesn't work in my script, that I write to the page in codebehind with...
7
by: sck10 | last post by:
Hello, I have the following sub in a class in my "App_Code" directory. The script is for setting focus on a particular control, but I get the error, "Name ClientScript Not declared". Also, I am...
2
by: verci | last post by:
Hi guys, I'm using asp.net 2.0, can anybody send me some complete examples on using ClientScript.RegisterClientScriptInclude and ClientScript.RegisterClientScriptSource, for registering an...
9
by: Dariusz Tomoń | last post by:
Hello, I'd like to include JS from C# code (ASP.NET 2.0). I'm trying not directly from i.e. default.aspx.cs code but from a class belonging to DLL, which is referred in my project. The code...
4
by: Jonathan Wood | last post by:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages. The sample contains the following within the <headtag: <script type="text/javascript" src="flashobject.js"></script>...
2
by: Scott M. | last post by:
The following code (VS 2008) does cause the script string to render, but it doesn't render inside of <scripttags, instead the result is rendered just after the opening <formtag, but outside of the...
25
by: premprakashbhati | last post by:
i want to have checkboxes in my gridview ...by checking it ,i can delete the row/rows.... so i have written code and got 2 Errors ...can anyone solve it... Error:1...'gridview.RetrieveItems()': not...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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.