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 / ASP.NET / General / October 2007

Tip: Looking for answers? Try searching our database.

ClientScript parm definitions

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rodchar - 15 Oct 2007 15:35 GMT
hey all,

can someone please explain in lamen's terms the following:
ClientScript.RegisterStartupScript(this.GetType(), "key2", "javascript
string", true);
what does this.GetType() mean?
what is the key2 parm used for?

thanks,
rodchar
George Ter-Saakov - 15 Oct 2007 16:09 GMT
Just imagine scenario you have a user control on the page.
And that user control is trying to add JavaScript function MyFunction to the
page.

so it's using RegisterScript.....

Now if you have 2 same user controls on the page. both of them will try to
add MyFunction to the page... Which is sort of a mistake. You will duplicate
definition.

So the right way to do it will be check if that function already exists or
not. That why we have "key2". ASP.NET gives you way to check is that script
already been added to the page.
-----------------------------------

now what happens if two different controls starting using same name "key2".
The get all confused. So ASP.NET gives you Type parameter. So they will not
mix.

Sort of like namespace.

George.

> hey all,
>
[quoted text clipped - 6 lines]
> thanks,
> rodchar
rodchar - 15 Oct 2007 17:20 GMT
i see GetType( ) a lot in intellisense for a lot of objects. is the reasoning
you gave the same for others that have the GetType( ) method?

> Just imagine scenario you have a user control on the page.
> And that user control is trying to add JavaScript function MyFunction to the
[quoted text clipped - 29 lines]
> > thanks,
> > rodchar
George Ter-Saakov - 15 Oct 2007 17:54 GMT
in .NET all objects are derived from System.Object

System.Object has several methods and GetType is one of them.
so naturally it will come up in intellisense.

It' just returns a "type" of that particular object.

George.

>i see GetType( ) a lot in intellisense for a lot of objects. is the
>reasoning
> you gave the same for others that have the GetType( ) method?
rodchar - 17 Oct 2007 17:00 GMT
thank you for making it pretty clear for me, i appreciate the effort.
rod.

> in .NET all objects are derived from System.Object
>
[quoted text clipped - 8 lines]
> >reasoning
> > you gave the same for others that have the GetType( ) method?

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.