473,545 Members | 1,977 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Add jscript at the end (with ClientScript.Re gisterClientScr iptBlock) ?

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

Thanks

Stan
Oct 6 '06 #1
3 2453
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.Re gisterClientScr iptBlock ?

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.Rende r( 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
RegisterClientS cript block renders the javascript after the <form>.
RegisterStartup Script renders before </form>.

-- bruce (sqlwork.com)

"Stan SR" <st**@pasdepam. netsunset.comwr ote in message
news:%2******** ********@TK2MSF TNGP04.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.Re gisterClientScr iptBlock ?

Thanks

Stan

Oct 6 '06 #3
Hi,

bruce barker (sqlwork.com) wrote:
RegisterClientS cript block renders the javascript after the <form>.
RegisterStartup Script 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
1130
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 site to combat that but now when I run the application instead of the pdf being viewed from IE it prompts me to either open it or download it. When I...
4
1942
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 activeX-2D-control. In codebehind, I use C# for the application logic (eg. the database access). The query to the database retuns me an object of a C#...
7
3280
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 "registerClientScriptBlock" as follows: string script = "<script language=jscript>"; script += "function test()";
7
4431
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 using MasterPages. How do I use "ClientScript.RegisterStartupScript" in a class? Public Shared Sub SetFocusControl(ByVal FocusControl As Control)...
2
29723
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 external javascript file (myfile.js) in my ASP page, I have not found any clear or complete examples, meaning in wich event handler should I put it in...
9
4292
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 is as follow: Page.ClientScript.RegisterClientScriptInclude(Page.GetType(),"swfobject.js","swfobject.js");
4
1678
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> <script type="text/javascript"> // <!.indexOf('='); if( pos == -1 ) { continue; // Look for "name=value"
2
4671
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 other <scripttags that are rendered automatically to handle my validation controls. protected void Page_Load(object sender, EventArgs e) {...
25
2695
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 all code paths return a value ,and Error:2...No overload for method 'DeleteRows' takes '1' arguments Here is my aspx.cs Code: using System;...
1
7439
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
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...
0
5987
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5343
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...
0
4962
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3468
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...
1
1901
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
1
1028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
722
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...

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.