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

ClientScript parm definitions

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
Oct 15 '07 #1
4 1337
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" <ro*****@discussions.microsoft.comwrote in message
news:DE**********************************@microsof t.com...
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

Oct 15 '07 #2
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" <ro*****@discussions.microsoft.comwrote in message
news:DE**********************************@microsof t.com...
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


Oct 15 '07 #3
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" <ro*****@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
>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?

Oct 15 '07 #4
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" <ro*****@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
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?


Oct 17 '07 #5

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

Similar topics

1
by: droope | last post by:
I am trying to create a proc with a parm @whereclause that will have a value passed in of one to many policy ids. The parm coming into the proc looks like this, ('000000000108', '000000000106',...
6
by: Angel | last post by:
I'm exporting (with DllImport) a C-style function with this syntax: int z9indqry (4_PARM *parm); 4_PARM is a structure declared in a proprietary header file that cannot be included in my...
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: Alex Maghen | last post by:
I want to create a C# class where I'll have a bunch of static functions which will use the ClientScript object to dump out some JavaScript dynamically. But I can't figure out how to get a hold of...
4
by: Jon Paal | last post by:
"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object reference". ... what reference is it looking for ?????? class...
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...
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...
1
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...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.