Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Javascript changes not saved

Reply
Thread Tools

Javascript changes not saved

 
 
ken s
Guest
Posts: n/a
 
      10-10-2006
I'm using Javascript to change a value in an asp:textbox control on an
asp.net page, then submitting the page and persisting the data using c# code.
I can see the value in the textbox change when the Javascript runs, but when
the page is submitted, the c# event code still sees the original value in the
textbox, not the value that was updated by Javascript.


Here’s the javascript code that changes the value:

document.forms[0].txt1.value = calcCigScore();
alert (document.forms[0].txt1.value);

The alert shows me that the value has changed (I can also see it change on
the page).


And here’s the c# code from the SaveRecord event on the aspx page:

mIntake.CigScore = int.Parse(txt1.Text);

When tracing through the code, I see that txt1.Text still equals the value
that was originally loaded into the page.

Is there a reason why .Net doesn’t see the updated value? Anything I can do
to change that?

Thanks

 
Reply With Quote
 
 
 
 
Cowboy \(Gregory A. Beamer\)
Guest
Posts: n/a
 
      10-11-2006
Most likely you are running up against ViewState. Set up Page_Init() and
look at the value there. Then, check again in Page_Load (ViewState runs
between the two).

It is also possible you are rebinding in Page_Load, which happens prior to
the event handlers for controls (button submit, for example).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com

*************************************************
Think outside of the box!
*************************************************
"ken s" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm using Javascript to change a value in an asp:textbox control on an
> asp.net page, then submitting the page and persisting the data using c#
> code.
> I can see the value in the textbox change when the Javascript runs, but
> when
> the page is submitted, the c# event code still sees the original value in
> the
> textbox, not the value that was updated by Javascript.
>
>
> Here's the javascript code that changes the value:
>
> document.forms[0].txt1.value = calcCigScore();
> alert (document.forms[0].txt1.value);
>
> The alert shows me that the value has changed (I can also see it change on
> the page).
>
>
> And here's the c# code from the SaveRecord event on the aspx page:
>
> mIntake.CigScore = int.Parse(txt1.Text);
>
> When tracing through the code, I see that txt1.Text still equals the value
> that was originally loaded into the page.
>
> Is there a reason why .Net doesn't see the updated value? Anything I can
> do
> to change that?
>
> Thanks
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript changes not saved =?Utf-8?B?a2VuIHM=?= ASP .Net 3 10-12-2006 08:06 AM
Javascript changes not saved =?Utf-8?B?a2VuIHM=?= ASP .Net 0 10-10-2006 10:04 PM
Javascript changes not saved =?Utf-8?B?a2VuIHM=?= ASP .Net 0 10-10-2006 10:03 PM



Advertisments