473,402 Members | 2,046 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Changing web control values from Javascript

Hi,

I have a strange problem here... I have a simple onclick event on an
ASP.NET button that does the following Javascript...

document.getElementById("Button1").text = "Cancelled";

However, when I inspect the Button1.text value from code behind the it
shows the original value of Button1 and not what the Javascript has
changed it to. The funny thing is that it works for an ASP.NET text
box, as follows:-

document.getElementById("TextBox1").value = "Marcus123";

Any help appreciated....

Marcus.
Nov 18 '05 #1
2 1892
"Form controls, such as TextBox and RadioButtonList, retain their values
between posts even when view state is disabled. The values of these
controls do not need to be preserved in the _VIEWSTATE hidden form field
becuase they are actually being submitted to the server on each form
post." - ASP.NET Unleashed

Sounds like to me the Textbox value is getting submitted to the server
automatically during post while the button text is discarded. Viewstate
isn't really involved here, since these values are being changed client
side. I only quoted that because it seems relevant in the description of
how a textbox is "different".

HTH,
Greg

"Marcus" <ma********@m2software.co.uk> wrote in message
news:a4**************************@posting.google.c om...
Hi,

I have a strange problem here... I have a simple onclick event on an
ASP.NET button that does the following Javascript...

document.getElementById("Button1").text = "Cancelled";

However, when I inspect the Button1.text value from code behind the it
shows the original value of Button1 and not what the Javascript has
changed it to. The funny thing is that it works for an ASP.NET text
box, as follows:-

document.getElementById("TextBox1").value = "Marcus123";

Any help appreciated....

Marcus.

Nov 18 '05 #2
Thanks Greg,

Strangely, it also doesn't work with label, literal and Radio form
controls either (Only a textbox form control). Even stranger, it "does"
work with a hidden HTML Text Box (with runat=server) but not with HTML
Radio Buttons (With runat=server).

Trial and error seems to be the idea with this one!

Let me know if you discover anything else.

Thanks,

Marcus
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: martin | last post by:
I needed a way to display calculated, multiple, changing values (numerical sums) as users interacted with the page, and do this without going back to the server to load the page again. What I...
0
by: Marcus | last post by:
Hi, I have a small piece of Javascript that executes when the Onclick event of an ASP.NET button is clicked and then finally changes the text value of an asp.net button control as follows:- ...
3
by: John | last post by:
I have an asp.net control which on the first Load of the page has a unique ID something like: _ctl0__ctl1_GroupName__ctl1_ControlName and after the first postback it changes to: ...
0
by: Sydem | last post by:
I have a classic ASP site that I'm converting to ASP.NET 2.0 using VS 2005 Beta 2 with the VB.NET language. In my classic ASP web app I use a custom Javascript that creates a menu "control". In...
11
by: saurabh | last post by:
Can anybody tell me how to change the value of an html control from the c#.... eg i hv one asp.net radio button control and one html hidden variable... so on page load in case the radio button is...
3
by: dcassar | last post by:
I am working on a complex server control that dynamically creates an HtmlInputHidden control that stores its value. As far as the postback process is concerned, this hidden input acts as the...
2
by: Gary Dale | last post by:
I have a form with a pull-down list with six options, each of which has a value set. The value is the e-mail account name (without the domain) of a group while the displayed value is the full name...
7
by: Christian Cambier | last post by:
Hi, I have a textbox in a web user control. I then add the usercontrol to a web form. I also add a label in the web form. Now, when I press a key in the textbox, i want to display some text...
3
by: mileshenley | last post by:
Hey there, This may be an ASP question but i think it is more of a JS question. I have a web form that i want to have database values loaded into. I have (and want) the form defaulting to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.