Hello, I've got the following elements on my page:
A Body tag that looks like this:
<body onload="setTabs ()">
A Javascript script in the <head> that has:
var foo;
function setTabs()
{
doSomething(foo );
}
I want my ASP.NET page to set the value of foo so that it gets used in the
setTabs() function onload of the page.
So, I tried the following in Page_Load()
string strScript = "<script language='javas cript'>foo=" +
Request.QuerySt ring["var"].ToString() + "; </script>";
if(!this.IsClie ntScriptBlockRe gistered("clien tScript"))
this.RegisterCl ientScriptBlock ("clientScript" , scriptString);
This obviously does not seem to work.I'm trying to therefore figure out, how
do I set the value of a client side javascript variable (foo) based on the
value of my serverside variable request.queryst ring["var"]?
Any help would be appreciated.
thanks,
fxs 4 1661
Hi
You could write the function like this...
function setTabs()
{
doSomething(<%= qsvar %>);
}
and your Page class should have...
public string qsvar="";
Page_Load()
{
qsvar = Page.Request.Qu eryString["var"];
}
You might be able to do it with without the variable, by just using <%=
Page.Request.Qu eryString["var"] %> in your Javascript - haven't tested this
tho!
HTH
Dan
"fxs" wrote: Hello, I've got the following elements on my page:
A Body tag that looks like this: <body onload="setTabs ()">
A Javascript script in the <head> that has: var foo; function setTabs() { doSomething(foo ); }
I want my ASP.NET page to set the value of foo so that it gets used in the setTabs() function onload of the page.
So, I tried the following in Page_Load()
string strScript = "<script language='javas cript'>foo=" + Request.QuerySt ring["var"].ToString() + "; </script>"; if(!this.IsClie ntScriptBlockRe gistered("clien tScript")) this.RegisterCl ientScriptBlock ("clientScript" , scriptString);
This obviously does not seem to work.I'm trying to therefore figure out, how do I set the value of a client side javascript variable (foo) based on the value of my serverside variable request.queryst ring["var"]?
Any help would be appreciated.
thanks, fxs
You can call Response.Write (strScript);
But the cleanest way is to pass data in a hidden input instead of setting a
client variable from the server.
Eliyahu
"fxs" <su****@xyant.c om> wrote in message
news:eB******** ******@TK2MSFTN GP09.phx.gbl... Hello, I've got the following elements on my page:
A Body tag that looks like this: <body onload="setTabs ()">
A Javascript script in the <head> that has: var foo; function setTabs() { doSomething(foo ); }
I want my ASP.NET page to set the value of foo so that it gets used in the setTabs() function onload of the page.
So, I tried the following in Page_Load()
string strScript = "<script language='javas cript'>foo=" + Request.QuerySt ring["var"].ToString() + "; </script>"; if(!this.IsClie ntScriptBlockRe gistered("clien tScript")) this.RegisterCl ientScriptBlock ("clientScript" ,
scriptString); This obviously does not seem to work.I'm trying to therefore figure out,
how do I set the value of a client side javascript variable (foo) based on the value of my serverside variable request.queryst ring["var"]?
Any help would be appreciated.
thanks, fxs
great. thanks! i'll try that!
"Eliyahu Goldin" <re************ *@monarchmed.co m> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. .. You can call Response.Write (strScript);
But the cleanest way is to pass data in a hidden input instead of setting a client variable from the server.
Eliyahu
"fxs" <su****@xyant.c om> wrote in message news:eB******** ******@TK2MSFTN GP09.phx.gbl... Hello, I've got the following elements on my page:
A Body tag that looks like this: <body onload="setTabs ()">
A Javascript script in the <head> that has: var foo; function setTabs() { doSomething(foo ); }
I want my ASP.NET page to set the value of foo so that it gets used in the setTabs() function onload of the page.
So, I tried the following in Page_Load()
string strScript = "<script language='javas cript'>foo=" + Request.QuerySt ring["var"].ToString() + "; </script>"; if(!this.IsClie ntScriptBlockRe gistered("clien tScript")) this.RegisterCl ientScriptBlock ("clientScript" , scriptString); This obviously does not seem to work.I'm trying to therefore figure out,
how do I set the value of a client side javascript variable (foo) based on the value of my serverside variable request.queryst ring["var"]?
Any help would be appreciated.
thanks, fxs
I tested <%=request.quer ystring("var")% > and that works -- however, I;d like
to be able to stay away from the asp style code-insertion tactics if i can.
How about creating a serverside input control type = hidden runat=server and
then trying to assign it a value on the page_load?
"dhnriversi de" <da*@musoswire. com> wrote in message
news:CC******** *************** ***********@mic rosoft.com... Hi
You could write the function like this...
function setTabs() { doSomething(<%= qsvar %>); }
and your Page class should have...
public string qsvar="";
Page_Load() { qsvar = Page.Request.Qu eryString["var"]; }
You might be able to do it with without the variable, by just using <%= Page.Request.Qu eryString["var"] %> in your Javascript - haven't tested this tho!
HTH
Dan "fxs" wrote:
Hello, I've got the following elements on my page:
A Body tag that looks like this: <body onload="setTabs ()">
A Javascript script in the <head> that has: var foo; function setTabs() { doSomething(foo ); }
I want my ASP.NET page to set the value of foo so that it gets used in the setTabs() function onload of the page.
So, I tried the following in Page_Load()
string strScript = "<script language='javas cript'>foo=" + Request.QuerySt ring["var"].ToString() + "; </script>"; if(!this.IsClie ntScriptBlockRe gistered("clien tScript")) this.RegisterCl ientScriptBlock ("clientScript" , scriptString);
This obviously does not seem to work.I'm trying to therefore figure out, how do I set the value of a client side javascript variable (foo) based on the value of my serverside variable request.queryst ring["var"]?
Any help would be appreciated.
thanks, fxs
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Zeebra3 |
last post by:
Here goes: I have a web form with several asp:dropdownlists, with
which, when selection is changed I want to fire an event defined in
some clientside js.
The content of the clientside code is dependant on data collected in
the code behind on the server. I have set AutoPostback to false for
the controls and added lines such as
cboMyCombo1.Attributes.Add("onchange", "MyCombos_OnChange('1')");
in the Page_Load event, which is rendered OK...
|
by: Alvin Bruney |
last post by:
I have a server side datagrid control. I'd like to clear the grid before the
post occurs using javascript. Anybody know how to do this? It would be a
similar effect to binding to a null dataset in the codebehind, sorta.
--
Regards,
Alvin Bruney
Got tidbits? Get it here...
http://tinyurl.com/3he3b
|
by: TJS |
last post by:
how do I get "onSubmit" to work in .net ?
<Form id="Form1" name="Form1" method="post" onSubmit="return
validateStandard(this, 'error');" runat="server">
|
by: Rob Shorney |
last post by:
Hi,
I am using .Net 2003 , c# asp.net.
The situation i have is this. I have a asp.net page which in the codebehind
maintains an xml document in memory. The user can click on a button to popup
a windows to select some items, this is done via window.open, I then return
the selected items via the returnValue, when I receive the data back I need
to be able to call into a function in my main page codebehind to update the
xml.
|
by: IkBenHet |
last post by:
Hello,
Currently I am using a large input form on a website that is based on
ASP and JavaScript.
Depending on the values that are filled in by the user the forms does a
refresh and makes other input fields available to fill in. I use the
JavaScript OnChange function (=clientside) that creates a querystring
and does a refresh of the page. It works fine.
| |
by: bill |
last post by:
I need to be able to dynamically add items to a <asp:listbox> (or HTML
<select runat=server>) using clientside javascript, and retrieve the items
when the page is posted back.
I use this code to add the option to the listbox. It works for <select> or
<asp:listbox> controls.
var opt = document.CreateElement("OPTION");
opt.text = "test";
opt.value="test";
|
by: susiedba |
last post by:
hey I used to be able to take VB6 code and paste it into a HTML page
and it would run on the clientside
does anyone know if this is possible in VB 2005?
Thanks
-Susie
|
by: John Kotuby |
last post by:
Hi all,
In ASP.NET 2.0 and VB.NET, I am trying to get the OnSelectedIndexChanged
event to fire a Javascript function. There is no OnClientClick event for
that control.
When I try something like:
OnSelectedIndexChanged="javascript:SetOwner('<%= lstOwner.ClientID %>');" I
get an error.
|
by: Anz |
last post by:
Is there any JavaScript function to generate a Beep sound from
system ?,
is it possible to make system Beep using JavaScript function ?
|
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...
|
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...
| |
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...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |