|
.net
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
parameter from JScript to Asp.netHi there,
Can anyone tell me a way to pass parameters from java script to ASP.net (VB.net)? Thanks "luke" <talktomyfri***@hotmail.com> wrote in message What are you trying to achieve with this...?news:%23Qe1ATMzGHA.1256@TK2MSFTNGP02.phx.gbl... > Can anyone tell me a way to pass parameters from java script to ASP.net 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...? >
Show quote
"luke" <talktomyfri***@hotmail.com> wrote in message Hmm - when you say "click on one button", is this the button which causes 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. 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. 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 > } > } > "luke" <talktomyfri***@hotmail.com> wrote in message I have no idea what you're doing...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. Please post the complete code for the page in question... luke napisa³(a):
> Hi there, Sure:)> > Can anyone tell me a way to pass parameters from java script to ASP.net > (VB.net)? 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 Hi,
Przemek Ptasznik wrote: Show quote > luke napisa³(a): All these solution imply a postback. I would like to add>> 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 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 The most common way is using hidden input fields:
<input type=hidden id=myParameter runat=server> They are accessible on both client and server. -- Show quoteEliyahu Goldin, Software Developer & Consultant Microsoft MVP [ASP.NET] "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 > > > > |
|||||||||||||||||||||||