473,320 Members | 1,820 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,320 software developers and data experts.

ClientScript.RegisterClientScriptBlock in ASP.NET 2.0

I am working on converting my code from ASP.NET 1.1 to ASP.NET 2.0. In
ASP.NET 1.1 the RegisterClientScriptBlock method was just a key and script
(2 Strings), but in ASP.NET the ClientScript.RegisterClientScriptBlock also
includes a parameter called 'type' which is of Type. This sounds like it is
supposed to specify whether the script is JavaScript, VBScript, JScript,
ECMAScript, etc., but I what am I supposed to enter here (I have not heard
of a value of Type that would specify this)? (I always use JavaScript for my
client-side scripts) Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jul 3 '06 #1
4 2591
Hi Nathan,

Try it like this:

ClientScript.RegisterStartupScript(Me.GetType, "Startup",
scriptString)
Ken
Microsoft MVP [ASP.NET]

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OI**************@TK2MSFTNGP04.phx.gbl...
>I am working on converting my code from ASP.NET 1.1 to ASP.NET 2.0. In
ASP.NET 1.1 the RegisterClientScriptBlock method was just a key and script
(2 Strings), but in ASP.NET the ClientScript.RegisterClientScriptBlock also
includes a parameter called 'type' which is of Type. This sounds like it is
supposed to specify whether the script is JavaScript, VBScript, JScript,
ECMAScript, etc., but I what am I supposed to enter here (I have not heard
of a value of Type that would specify this)? (I always use JavaScript for
my client-side scripts) Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jul 3 '06 #2
Hi Nathan

RegisterClientScriptBlock doesn't know about client side scripting, the
parameter type is the object 'type', You usually get this with GetType()
method.

See ya
daniel #

"Nathan Sokalski" <nj********@hotmail.comwrote in message
news:OI**************@TK2MSFTNGP04.phx.gbl...
>I am working on converting my code from ASP.NET 1.1 to ASP.NET 2.0. In
ASP.NET 1.1 the RegisterClientScriptBlock method was just a key and script
(2 Strings), but in ASP.NET the ClientScript.RegisterClientScriptBlock also
includes a parameter called 'type' which is of Type. This sounds like it is
supposed to specify whether the script is JavaScript, VBScript, JScript,
ECMAScript, etc., but I what am I supposed to enter here (I have not heard
of a value of Type that would specify this)? (I always use JavaScript for
my client-side scripts) Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jul 3 '06 #3
The C# flavor would be:

ClientScript.RegisterStartupScript(typeof(this), "Startup",
scriptString)

I was hoping an MVP would say why they decided to associate scripts with the
pages that contain them; I'm assuming that the same script manager object is
shared throughout the web site.

"Nathan Sokalski" wrote:
I am working on converting my code from ASP.NET 1.1 to ASP.NET 2.0. In
ASP.NET 1.1 the RegisterClientScriptBlock method was just a key and script
(2 Strings), but in ASP.NET the ClientScript.RegisterClientScriptBlock also
includes a parameter called 'type' which is of Type. This sounds like it is
supposed to specify whether the script is JavaScript, VBScript, JScript,
ECMAScript, etc., but I what am I supposed to enter here (I have not heard
of a value of Type that would specify this)? (I always use JavaScript for my
client-side scripts) Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/
Jul 3 '06 #4
William, its just to give you a much better option to identifying script
files. Basically if you just provided a key string, this will surely make it
unique but if the key was associated to a particular control, it wont clash
with other controls that might be using the same key to identify their
scripts, since now my key is prefixed to my control.

Specially if you are a control author, this is useful since I dont know what
kind of key the end user might want to use to uniquely identify his other
script files. I dont want to assume what it might be either, so if i can
prefix this with the type of my control i have a better chance of making the
key unique and avoid any un-necessary clashes or limiting the end user. I
guess you can consider specfying a type as providing a namespace.

This is also hinted in the documentation :
"A client script is uniquely identified by its key and its type. Scripts
with the same key and type are considered duplicates"
Regards,
Alessandro Zifiglio
http://www.AsyncUI.net
"William Sullivan" <Wi*************@discussions.microsoft.comha scritto
nel messaggio news:FA**********************************@microsof t.com...
The C# flavor would be:

ClientScript.RegisterStartupScript(typeof(this), "Startup",
scriptString)

I was hoping an MVP would say why they decided to associate scripts with
the
pages that contain them; I'm assuming that the same script manager object
is
shared throughout the web site.

"Nathan Sokalski" wrote:
>I am working on converting my code from ASP.NET 1.1 to ASP.NET 2.0. In
ASP.NET 1.1 the RegisterClientScriptBlock method was just a key and
script
(2 Strings), but in ASP.NET the ClientScript.RegisterClientScriptBlock
also
includes a parameter called 'type' which is of Type. This sounds like it
is
supposed to specify whether the script is JavaScript, VBScript, JScript,
ECMAScript, etc., but I what am I supposed to enter here (I have not
heard
of a value of Type that would specify this)? (I always use JavaScript for
my
client-side scripts) Thanks.
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

Jul 3 '06 #5

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

Similar topics

1
by: Jeremy McPeak | last post by:
Howdy. First of all, awesome job on .NET 2.0! Now to my question: I love Master Pages and the Page.ClientScript; however, I am having trouble getting the two to play together. I can build a...
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: mac | last post by:
I have a requirement to open a popup window in button click event(after server processing). The way i use is i call Page.RegisterClientScriptBlock to register script for opening popup in the button...
4
by: Nathan Sokalski | last post by:
I am working on converting my code from ASP.NET 1.1 to ASP.NET 2.0. In ASP.NET 1.1 the RegisterClientScriptBlock method was just a key and script (2 Strings), but in ASP.NET the...
3
by: Stan SR | last post by:
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
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...
1
by: HockeyFan | last post by:
My function to get an alert box on the page isn't working. Instead it puts in the bottom section of the page: <script type="text/javascript"> <!-- This is a test// --> </script> The...
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...
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...
5
by: Tony | last post by:
Hi, I have two questions: 1) With this code, i never see the alert message. Why? How to see it? Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "myscript", _ " alert('you go to...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

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.