Home All Groups Group Topic Archive Search About

parameter from JScript to Asp.net

Author
31 Aug 2006 6:14 AM
luke
Hi there,

Can anyone tell me a way to pass parameters from java script to ASP.net
(VB.net)?


Thanks

Author
31 Aug 2006 6:34 AM
Mark Rae
"luke" <talktomyfri***@hotmail.com> wrote in message
news:%23Qe1ATMzGHA.1256@TK2MSFTNGP02.phx.gbl...

> Can anyone tell me a way to pass parameters from java script to ASP.net

What are you trying to achieve with this...?
Author
31 Aug 2006 7:39 AM
luke
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

Show quote
"Mark Rae" <mark@markNOSPAMrae.com> wrote in message
news:O5UKHeMzGHA.4648@TK2MSFTNGP04.phx.gbl...
> "luke" <talktomyfri***@hotmail.com> wrote in message
> news:%23Qe1ATMzGHA.1256@TK2MSFTNGP02.phx.gbl...
>
>> Can anyone tell me a way to pass parameters from java script to ASP.net
>
> What are you trying to achieve with this...?
>
Author
31 Aug 2006 8:18 AM
Mark Rae
Show quote
"luke" <talktomyfri***@hotmail.com> wrote in message
news:%23EsKSCNzGHA.3424@TK2MSFTNGP03.phx.gbl...

> 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
    }
}
Author
31 Aug 2006 10:38 AM
luke
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.



Show quote
"Mark Rae" <mark@markNOSPAMrae.com> wrote in message
news:%239uBBYNzGHA.1536@TK2MSFTNGP02.phx.gbl...
> "luke" <talktomyfri***@hotmail.com> wrote in message
> news:%23EsKSCNzGHA.3424@TK2MSFTNGP03.phx.gbl...
>
>> 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
>    }
> }
>
Author
31 Aug 2006 12:15 PM
Mark Rae
"luke" <talktomyfri***@hotmail.com> wrote in message
news:urAGNmOzGHA.3440@TK2MSFTNGP06.phx.gbl...

>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...
Author
31 Aug 2006 7:14 AM
Przemek Ptasznik
luke napisa³(a):
> 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
Author
31 Aug 2006 7:40 AM
Laurent Bugnion
Hi,

Przemek Ptasznik wrote:
Show quote
> luke napisa³(a):
>> 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
Author
31 Aug 2006 7:56 AM
Eliyahu Goldin
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]


Show quote
"luke" <talktomyfri***@hotmail.com> wrote in message
news:%23Qe1ATMzGHA.1256@TK2MSFTNGP02.phx.gbl...
> Hi there,
>
> Can anyone tell me a way to pass parameters from java script to ASP.net
> (VB.net)?
>
>
> Thanks
>
>
>
>

AddThis Social Bookmark Button