PC Review


Reply
Thread Tools Rate Thread

ClientScript parm definitions

 
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      15th Oct 2007
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
 
Reply With Quote
 
 
 
 
George Ter-Saakov
Guest
Posts: n/a
 
      15th Oct 2007
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.






"rodchar" <(E-Mail Removed)> wrote in message
newsE834DDE-A0CA-416A-9A0A-(E-Mail Removed)...
> 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



 
Reply With Quote
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      15th Oct 2007
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?

"George Ter-Saakov" wrote:

> 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.
>
>
>
>
>
>
> "rodchar" <(E-Mail Removed)> wrote in message
> newsE834DDE-A0CA-416A-9A0A-(E-Mail Removed)...
> > 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

>
>
>

 
Reply With Quote
 
George Ter-Saakov
Guest
Posts: n/a
 
      15th Oct 2007
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.

"rodchar" <(E-Mail Removed)> wrote in message
news:0E69B754-40DB-4470-B65A-(E-Mail Removed)...
>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?
>



 
Reply With Quote
 
=?Utf-8?B?cm9kY2hhcg==?=
Guest
Posts: n/a
 
      17th Oct 2007
thank you for making it pretty clear for me, i appreciate the effort.
rod.

"George Ter-Saakov" wrote:

> 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.
>
> "rodchar" <(E-Mail Removed)> wrote in message
> news:0E69B754-40DB-4470-B65A-(E-Mail Removed)...
> >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?
> >

>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Parm Not Getting Passed? PeteCresswell Microsoft Access 2 11th Apr 2008 05:50 PM
pass more than one parm =?Utf-8?B?cm9kY2hhcg==?= Microsoft ASP .NET 2 14th Feb 2007 06:28 PM
Need to Parm Form Name in VBA =?Utf-8?B?QkNQ?= Microsoft Access VBA Modules 3 5th Jul 2006 06:49 PM
Query working with on parm but not another parm =?Utf-8?B?amJydWVu?= Microsoft Access Queries 0 2nd Feb 2006 08:33 PM
Parm nothing or something syntax Dean Slindee Microsoft Access ADP SQL Server 1 20th Nov 2003 12:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:54 PM.