473,770 Members | 1,778 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help with Registering Client Scripts

I'm trying to duplicate an HTML sample I have using my ASP.NET pages.

The sample contains the following within the <headtag:

<script type="text/javascript" src="flashobjec t.js"></script>
<script type="text/javascript">
// <![CDATA[
var args = new Object();
var query = location.search .substring(1);
// Get query string
var pairs = query.split( "," );
// Break at comma
for ( var i = 0; i < pairs.length; i++ )
{
var pos = pairs[i].indexOf('=');
if( pos == -1 )
{
continue; // Look for "name=value "
}
var argname = pairs[i].substring( 0, pos ); // If not found, skip
var value = pairs[i].substring( pos + 1 ); // Extract the name
args[argname] = unescape( value ); // Extract the value
}
// ]]>
</script>

To do this the ASP.NET way, I added the following code to my Page_Load
handler:

if (!Page.ClientSc ript.IsClientSc riptBlockRegist ered("FlashObje ct"))
Page.ClientScri pt.RegisterClie ntScriptInclude (typeof(Page),
"FlashObjec t", "flashobject.js ");

if (!Page.ClientSc ript.IsStartupS criptRegistered ("PrepVideo" ))
Page.ClientScri pt.RegisterStar tupScript(typeo f(Page), "PrepVideo" ,
"var args=new Object();" +
"var query=location. search.substrin g(1);" +
"var pairs=query.spl it(',');" +
"for (var i=0;i < pairs.length;i+ +){" +
"var pos=pairs[i].indexOf('=');" +
"if (pos==-1) continue;" +
"var argname=pairs[i].substring(0,po s);" +
"var value=pairs[i].substring(pos + 1);" +
"args[argname]=unescape(value );}", true);
}

I assume the second script is a start-up script since it is not a callable
function. So this seems like it should work but it does not duplicate the
functionality of the sample.

Looking at the HTML produced, I see neither registered scripts are placed
within the <headtag. So instead of calling RegisterClientS criptInclude and
RegisterStartup Script, I instead forced these scripts into the <headtag
and they WORKED!!

Unfortunately, I need to put this in a control that really should register
the scripts in an organized way.

Is there any way to register a script such that it is inserted within the
<headtag? Or perhaps there's something else I'm missing?

Thanks.

Jonathan

Jun 27 '08 #1
4 1687
On Jun 7, 11:08*am, "Jonathan Wood" <jw...@softcirc uits.comwrote:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages.

The sample contains the following within the <headtag:

* *<script type="text/javascript" src="flashobjec t.js"></script>
* *<script type="text/javascript">
* * * // <![CDATA[
* * * var args = new Object();
* * * var query = location.search .substring(1);
* * * // Get query string
* * * var pairs = query.split( "," );
* * * // Break at comma
* * * for ( var i = 0; i < pairs.length; i++ )
* * * {
* * * * *var pos = pairs[i].indexOf('=');
* * * * *if( pos == -1 )
* * * * *{
* * * * * * continue; // Look for "name=value "
* * * * *}
* * * * *var argname = pairs[i].substring( 0, pos ); // If notfound, skip
* * * * *var value = pairs[i].substring( pos + 1 ); // Extractthe name
* * * * *args[argname] = unescape( value ); // Extract the value
* * * }
* * * // ]]>
* *</script>

To do this the ASP.NET way, I added the following code to my Page_Load
handler:

* if (!Page.ClientSc ript.IsClientSc riptBlockRegist ered("FlashObje ct"))
* *Page.ClientScr ipt.RegisterCli entScriptInclud e(typeof(Page),
"FlashObjec t", "flashobject.js ");

* if (!Page.ClientSc ript.IsStartupS criptRegistered ("PrepVideo" ))
* *Page.ClientScr ipt.RegisterSta rtupScript(type of(Page), "PrepVideo" ,
* * "var args=new Object();" +
* * "var query=location. search.substrin g(1);" +
* * "var pairs=query.spl it(',');" +
* * "for (var i=0;i < pairs.length;i+ +){" +
* * "var pos=pairs[i].indexOf('=');" +
* * "if (pos==-1) continue;" +
* * "var argname=pairs[i].substring(0,po s);" +
* * "var value=pairs[i].substring(pos + 1);" +
* * "args[argname]=unescape(value );}", true);
*}

I assume the second script is a start-up script since it is not a callable
function. So this seems like it should work but it does not duplicate the
functionality of the sample.

Looking at the HTML produced, I see neither registered scripts are placed
within the <headtag. So instead of calling RegisterClientS criptInclude and
RegisterStartup Script, I instead forced these scripts into the <headtag
and they WORKED!!

Unfortunately, I need to put this in a control that really should register
the scripts in an organized way.

Is there any way to register a script such that it is inserted within the
<headtag? Or perhaps there's something else I'm missing?

Thanks.

Jonathan
Hi

use this method to check wheiter script already added or not...

Page.ClientScri pt.IsClientScri ptBlockRegister ed();

and to register use

Page.ClientScri pt.RegisterClie ntScriptBlock() ;

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #2
use this method to check wheiter script already added or not...
>
Page.ClientScri pt.IsClientScri ptBlockRegister ed();

and to register use

Page.ClientScri pt.RegisterClie ntScriptBlock() ;
Well, thanks. But not only does this not address the problem I've described,
you're telling me to do exactly what the code I posted shows I was already
doing.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Munna" <mu******@gmail .comwrote in message
news:08******** *************** ***********@j1g 2000prb.googleg roups.com...
On Jun 7, 11:08 am, "Jonathan Wood" <jw...@softcirc uits.comwrote:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages.

The sample contains the following within the <headtag:

<script type="text/javascript" src="flashobjec t.js"></script>
<script type="text/javascript">
// <![CDATA[
var args = new Object();
var query = location.search .substring(1);
// Get query string
var pairs = query.split( "," );
// Break at comma
for ( var i = 0; i < pairs.length; i++ )
{
var pos = pairs[i].indexOf('=');
if( pos == -1 )
{
continue; // Look for "name=value "
}
var argname = pairs[i].substring( 0, pos ); // If not found, skip
var value = pairs[i].substring( pos + 1 ); // Extract the name
args[argname] = unescape( value ); // Extract the value
}
// ]]>
</script>

To do this the ASP.NET way, I added the following code to my Page_Load
handler:

if (!Page.ClientSc ript.IsClientSc riptBlockRegist ered("FlashObje ct"))
Page.ClientScri pt.RegisterClie ntScriptInclude (typeof(Page),
"FlashObjec t", "flashobject.js ");

if (!Page.ClientSc ript.IsStartupS criptRegistered ("PrepVideo" ))
Page.ClientScri pt.RegisterStar tupScript(typeo f(Page), "PrepVideo" ,
"var args=new Object();" +
"var query=location. search.substrin g(1);" +
"var pairs=query.spl it(',');" +
"for (var i=0;i < pairs.length;i+ +){" +
"var pos=pairs[i].indexOf('=');" +
"if (pos==-1) continue;" +
"var argname=pairs[i].substring(0,po s);" +
"var value=pairs[i].substring(pos + 1);" +
"args[argname]=unescape(value );}", true);
}

I assume the second script is a start-up script since it is not a callable
function. So this seems like it should work but it does not duplicate the
functionality of the sample.

Looking at the HTML produced, I see neither registered scripts are placed
within the <headtag. So instead of calling RegisterClientS criptInclude
and
RegisterStartup Script, I instead forced these scripts into the <headtag
and they WORKED!!

Unfortunately, I need to put this in a control that really should register
the scripts in an organized way.

Is there any way to register a script such that it is inserted within the
<headtag? Or perhaps there's something else I'm missing?

Thanks.

Jonathan

Jun 27 '08 #3
On Jun 7, 11:55 am, "Jonathan Wood" <jw...@softcirc uits.comwrote:
use this method to check wheiter script already added or not...
Page.ClientScri pt.IsClientScri ptBlockRegister ed();
and to register use
Page.ClientScri pt.RegisterClie ntScriptBlock() ;

Well, thanks. But not only does this not address the problem I've described,
you're telling me to do exactly what the code I posted shows I was already
doing.

--
Jonathan Wood
SoftCircuits Programminghttp ://www.softcircuit s.com

"Munna" <munna...@gmail .comwrote in message

news:08******** *************** ***********@j1g 2000prb.googleg roups.com...
On Jun 7, 11:08 am, "Jonathan Wood" <jw...@softcirc uits.comwrote:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages.
The sample contains the following within the <headtag:
<script type="text/javascript" src="flashobjec t.js"></script>
<script type="text/javascript">
// <![CDATA[
var args = new Object();
var query = location.search .substring(1);
// Get query string
var pairs = query.split( "," );
// Break at comma
for ( var i = 0; i < pairs.length; i++ )
{
var pos = pairs[i].indexOf('=');
if( pos == -1 )
{
continue; // Look for "name=value "
}
var argname = pairs[i].substring( 0, pos ); // If not found, skip
var value = pairs[i].substring( pos + 1 ); // Extract the name
args[argname] = unescape( value ); // Extract the value
}
// ]]>
</script>
To do this the ASP.NET way, I added the following code to my Page_Load
handler:
if (!Page.ClientSc ript.IsClientSc riptBlockRegist ered("FlashObje ct"))
Page.ClientScri pt.RegisterClie ntScriptInclude (typeof(Page),
"FlashObjec t", "flashobject.js ");
if (!Page.ClientSc ript.IsStartupS criptRegistered ("PrepVideo" ))
Page.ClientScri pt.RegisterStar tupScript(typeo f(Page), "PrepVideo" ,
"var args=new Object();" +
"var query=location. search.substrin g(1);" +
"var pairs=query.spl it(',');" +
"for (var i=0;i < pairs.length;i+ +){" +
"var pos=pairs[i].indexOf('=');" +
"if (pos==-1) continue;" +
"var argname=pairs[i].substring(0,po s);" +
"var value=pairs[i].substring(pos + 1);" +
"args[argname]=unescape(value );}", true);
}
I assume the second script is a start-up script since it is not a callable
function. So this seems like it should work but it does not duplicate the
functionality of the sample.
Looking at the HTML produced, I see neither registered scripts are placed
within the <headtag. So instead of calling RegisterClientS criptInclude
and
RegisterStartup Script, I instead forced these scripts into the <headtag
and they WORKED!!
Unfortunately, I need to put this in a control that really should register
the scripts in an organized way.
Is there any way to register a script such that it is inserted within the
<headtag? Or perhaps there's something else I'm missing?
Thanks.
Jonathan
Hi Jonathan

"RegisterStartu pScript" add scripts just before the end of "</body>"
tag..
and "RegisterClient ScriptBlock" add script inside the form as far as i
seen so far..
well since you need the script in the head block here is a work around
i found and worked for me...

i added a literal control in size the head tag

<head id="Myhead" runat="server">
<title>Untitl ed Page</title>
<asp:Literal ID="ScriptSourc e" runat="server"> </asp:Literal>
</head>

and in page load event i did this

ScriptSource.Te xt = "<script>window .alert('Worked okay');</script>";

surely you need to do some coding to adjust what you want to insert in
head...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #4
I figured this out. Turns out that it is not necessary for these scripts to
be within the <headtag. I don't understand exactly how they are used but
if I don't register the second script as a startup script and instead
register it as a regular client script block, it appears to work just fine.
Thanks.

--
Jonathan Wood
SoftCircuits Programming
http://www.softcircuits.com

"Munna" <mu******@gmail .comwrote in message
news:d5******** *************** ***********@z24 g2000prf.google groups.com...
On Jun 7, 11:55 am, "Jonathan Wood" <jw...@softcirc uits.comwrote:
use this method to check wheiter script already added or not...
Page.ClientScri pt.IsClientScri ptBlockRegister ed();
and to register use
Page.ClientScri pt.RegisterClie ntScriptBlock() ;

Well, thanks. But not only does this not address the problem I've
described,
you're telling me to do exactly what the code I posted shows I was
already
doing.

--
Jonathan Wood
SoftCircuits Programminghttp ://www.softcircuit s.com

"Munna" <munna...@gmail .comwrote in message

news:08******* *************** ************@j1 g2000prb.google groups.com...
On Jun 7, 11:08 am, "Jonathan Wood" <jw...@softcirc uits.comwrote:
I'm trying to duplicate an HTML sample I have using my ASP.NET pages.
The sample contains the following within the <headtag:
<script type="text/javascript" src="flashobjec t.js"></script>
<script type="text/javascript">
// <![CDATA[
var args = new Object();
var query = location.search .substring(1);
// Get query string
var pairs = query.split( "," );
// Break at comma
for ( var i = 0; i < pairs.length; i++ )
{
var pos = pairs[i].indexOf('=');
if( pos == -1 )
{
continue; // Look for "name=value "
}
var argname = pairs[i].substring( 0, pos ); // If not found, skip
var value = pairs[i].substring( pos + 1 ); // Extract the name
args[argname] = unescape( value ); // Extract the value
}
// ]]>
</script>
To do this the ASP.NET way, I added the following code to my Page_Load
handler:
if (!Page.ClientSc ript.IsClientSc riptBlockRegist ered("FlashObje ct"))
Page.ClientScri pt.RegisterClie ntScriptInclude (typeof(Page),
"FlashObjec t", "flashobject.js ");
if (!Page.ClientSc ript.IsStartupS criptRegistered ("PrepVideo" ))
Page.ClientScri pt.RegisterStar tupScript(typeo f(Page), "PrepVideo" ,
"var args=new Object();" +
"var query=location. search.substrin g(1);" +
"var pairs=query.spl it(',');" +
"for (var i=0;i < pairs.length;i+ +){" +
"var pos=pairs[i].indexOf('=');" +
"if (pos==-1) continue;" +
"var argname=pairs[i].substring(0,po s);" +
"var value=pairs[i].substring(pos + 1);" +
"args[argname]=unescape(value );}", true);
}
I assume the second script is a start-up script since it is not a
callable
function. So this seems like it should work but it does not duplicate
the
functionality of the sample.
Looking at the HTML produced, I see neither registered scripts are
placed
within the <headtag. So instead of calling
RegisterClientS criptInclude
and
RegisterStartup Script, I instead forced these scripts into the <head>
tag
and they WORKED!!
Unfortunately, I need to put this in a control that really should
register
the scripts in an organized way.
Is there any way to register a script such that it is inserted within
the
<headtag? Or perhaps there's something else I'm missing?
Thanks.
Jonathan

Hi Jonathan

"RegisterStartu pScript" add scripts just before the end of "</body>"
tag..
and "RegisterClient ScriptBlock" add script inside the form as far as i
seen so far..
well since you need the script in the head block here is a work around
i found and worked for me...

i added a literal control in size the head tag

<head id="Myhead" runat="server">
<title>Untitl ed Page</title>
<asp:Literal ID="ScriptSourc e" runat="server"> </asp:Literal>
</head>

and in page load event i did this

ScriptSource.Te xt = "<script>window .alert('Worked okay');</script>";

surely you need to do some coding to adjust what you want to insert in
head...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
Jun 27 '08 #5

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

Similar topics

4
10147
by: usl2222 | last post by:
Hi folks, I appreciate any assistance in the following problem: I have a form with a bunch of dynamic controls on it. All the controls are dynamically generated on a server, including all the validators. The user enters the data, presses OK. My OK button is dynamically generated as well, with some code-behind logic in
2
5712
by: Miguel | last post by:
Hi, I'm developing an application in C# with Windows Forms for my company that is similar to the MSN Messenger. This application uses a webservice for registering users, etc... and as 2 webbrowser controls on it. Besides that i'm using the firewall client for isa server 2004 and it seems that the browsers aren't able to pass thru it... if i disable the firewall the browsers work fine, if i don't, the 2 browsers just stay there...
8
3020
by: David Thielen | last post by:
Hi; In our setup program how do I determine if I need to run "aspnet_regiis –i" and if so, is there an API I can calll rather than finding that program on the user's disk and calling it? -- thanks - dave david_at_windward_dot_net http://www.windwardreports.com
0
1693
by: Global Infotech Corporation | last post by:
Hi We have the following two positions open at one of our Client's site in the Silicon Valley, CA area. Our client, apart from being a pioneer in desktop publishing software provider, also makes web publishing products. We are looking for two individuals with thorough understanding of the Quality Engineering process, testing tools and techniques. Please reveiew the positions listed below and let us know which of these you may want to...
1
2187
by: shivkumar2004 | last post by:
Hi!, I am developing a chat system using vb.net in vs 2005. I am getting the following error while registering the events. error details: System.InvalidOperationException was unhandled Message="An error occurred creating the form. See Exception.InnerException for details. The error is: Type System.DelegateSerializationHolder and the types derived from it (such as System.DelegateSerializationHolder) are not permitted to be
0
1208
by: shivkumar2004 | last post by:
Hi, I m getting the following error while registering the events on client appl. error: "An error occurred creating the form. See Exception.InnerException for details. The error is: Exception has been thrown by the target of an invocation."
0
984
by: applejump | last post by:
Hi all, I'm a Python beginner and trying to run the codes from Chapter 5 of Python pramming on win32. But when I tested the COM object with VBA, I got an error msg saying runtime error 438. Is there anyone can help me out? Thanks in advance! Here are the codes: class PythonUtilities: _public_methods_ = _reg_progid_ = "PythonDemos.Utilities" _reg_clsid_ = "{D81903FB-62F2-4FB1-993E-63CAF4C963A0}"
0
1127
by: davidj411 | last post by:
when does is make sense to use a ASP style Page (.psp) over a Python- based CGI script with IIS. ? http://support.microsoft.com/kb/276494 ASP requires registering the python engine. which has better performance? The ASP style uses a new part of the python language which is
0
9617
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10257
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10099
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10037
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7456
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6710
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5354
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.