Can anyone tell me a way to pass parameters from java script to ASP.net
(VB.net)?
Thanks"luke" <talktomyfriend@.hotmail.comwrote in message
news:%23Qe1ATMzGHA.1256@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
Can anyone tell me a way to pass parameters from java script to ASP.net
What are you trying to achieve with this...?
The most common way is using hidden input fields:
<input type=hidden id=myParameter runat=server>
They are accessible on both client and server.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
"luke" <talktomyfriend@.hotmail.comwrote in message
news:%23Qe1ATMzGHA.1256@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
Hi there,
>
Can anyone tell me a way to pass parameters from java script to ASP.net
(VB.net)?
>
>
Thanks
>
>
>
>
luke napisa(a):
Quote:
Originally Posted by
Hi there,
>
Can anyone tell me a way to pass parameters from java script to ASP.net
(VB.net)?
Sure:)
You have few options:
1) pass it as parameter in url while redirecting with location.replace()
2) pass it as field in form (most likely hidden field)
3) pass it in cookie which is modified from js.
--
PP
In the application's html, the code is:
<SCRIPT language="JAVASCRIPT" ....
........
function update_temperature(x, y) {
document.Form1.txtTemperatureX.value= x;
document.Form1.txtTemperatureY.value= y;
}
......
I can pass the values to txtTemperatureX and Y (only visible) in server
section, however when I click on one button which suppose to pick up the
value of txtTemperatureX and Y, but it is not at all,. Simply not updating
the page and change the old value from txtTemperatureX and Y.
If any help would be appreciated.
Thanks.
I try to find a better way to pass parameters
"Mark Rae" <mark@.markNOSPAMrae.comwrote in message
news:O5UKHeMzGHA.4648@.TK2MSFTNGP04.phx.gbl...
Quote:
Originally Posted by
"luke" <talktomyfriend@.hotmail.comwrote in message
news:%23Qe1ATMzGHA.1256@.TK2MSFTNGP02.phx.gbl...
>
Quote:
Originally Posted by
>Can anyone tell me a way to pass parameters from java script to ASP.net
>
What are you trying to achieve with this...?
>
Hi,
Przemek Ptasznik wrote:
Quote:
Originally Posted by
luke napisa(a):
Quote:
Originally Posted by
>Hi there,
>>
>Can anyone tell me a way to pass parameters from java script to
>ASP.net (VB.net)?
>
Sure:)
>
You have few options:
1) pass it as parameter in url while redirecting with location.replace()
2) pass it as field in form (most likely hidden field)
3) pass it in cookie which is modified from js.
>
--
PP
All these solution imply a postback. I would like to add
4) AJAX
Greetings,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
"luke" <talktomyfriend@.hotmail.comwrote in message
news:%23EsKSCNzGHA.3424@.TK2MSFTNGP03.phx.gbl...
Quote:
Originally Posted by
In the application's html, the code is:
>
<SCRIPT language="JAVASCRIPT" ....
.......
function update_temperature(x, y) {
document.Form1.txtTemperatureX.value= x;
document.Form1.txtTemperatureY.value= y;
}
>
......
>
I can pass the values to txtTemperatureX and Y (only visible) in server
section, however when I click on one button which suppose to pick up the
value of txtTemperatureX and Y, but it is not at all,. Simply not updating
the page and change the old value from txtTemperatureX and Y.
>
If any help would be appreciated.
Hmm - when you say "click on one button", is this the button which causes
the postback? In which case, I wonder if you are populating the values of
the two textboxes every time the page loads... If this is the case, then the
form fields will always have their original values e.g.
protected void Page_Load(object sender, System.EventArgs e)
{
// fetch data
// populate form fields
}
should be
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostback)
{
// fetch data
// populate form fields
}
}
I did use the approach as you said, however it seems the java script in html
didn't refresh the page at all, or somehow it postback to the old value but
it visually looks like the new value has been changed.
"Mark Rae" <mark@.markNOSPAMrae.comwrote in message
news:%239uBBYNzGHA.1536@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
"luke" <talktomyfriend@.hotmail.comwrote in message
news:%23EsKSCNzGHA.3424@.TK2MSFTNGP03.phx.gbl...
>
Quote:
Originally Posted by
>In the application's html, the code is:
>>
><SCRIPT language="JAVASCRIPT" ....
>.......
>function update_temperature(x, y) {
>document.Form1.txtTemperatureX.value= x;
>document.Form1.txtTemperatureY.value= y;
>}
>>
>......
>>
>I can pass the values to txtTemperatureX and Y (only visible) in server
>section, however when I click on one button which suppose to pick up the
>value of txtTemperatureX and Y, but it is not at all,. Simply not
>updating the page and change the old value from txtTemperatureX and Y.
>>
>If any help would be appreciated.
>
Hmm - when you say "click on one button", is this the button which causes
the postback? In which case, I wonder if you are populating the values of
the two textboxes every time the page loads... If this is the case, then
the form fields will always have their original values e.g.
>
protected void Page_Load(object sender, System.EventArgs e)
{
// fetch data
// populate form fields
}
>
should be
>
protected void Page_Load(object sender, System.EventArgs e)
{
if (!Page.IsPostback)
{
// fetch data
// populate form fields
}
}
>
"luke" <talktomyfriend@.hotmail.comwrote in message
news:urAGNmOzGHA.3440@.TK2MSFTNGP06.phx.gbl...
Quote:
Originally Posted by
>I did use the approach as you said, however it seems the java script in
>html didn't refresh the page at all, or somehow it postback to the old
>value but it visually looks like the new value has been changed.
I have no idea what you're doing...
Please post the complete code for the page in question...
0 comments:
Post a Comment