Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

ClientScript.RegisterClientScriptBlock in ASP.NET 2.0

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Nathan Sokalski - 03 Jul 2006 02:00 GMT
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.
Signature

Nathan Sokalski
njsokalski@hotmail.com
http://www.nathansokalski.com/

Ken Cox [Microsoft MVP] - 03 Jul 2006 02:29 GMT
Hi Nathan,

Try it like this:

       ClientScript.RegisterStartupScript(Me.GetType, "Startup",
scriptString)

Ken
Microsoft MVP [ASP.NET]

>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
[quoted text clipped - 4 lines]
>of a value of Type that would specify this)? (I always use JavaScript for
>my client-side scripts) Thanks.
daniel # - 03 Jul 2006 04:53 GMT
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 #

>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
[quoted text clipped - 4 lines]
>of a value of Type that would specify this)? (I always use JavaScript for
>my client-side scripts) Thanks.
William Sullivan - 03 Jul 2006 13:31 GMT
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.

> 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
[quoted text clipped - 4 lines]
> of a value of Type that would specify this)? (I always use JavaScript for my
> client-side scripts) Thanks.
Alessandro Zifiglio - 03 Jul 2006 15:22 GMT
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
> The C# flavor would be:
>
[quoted text clipped - 20 lines]
>> my
>> client-side scripts) Thanks.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.