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
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
Comment