473,513 Members | 2,493 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resets to default value when clicking a button

I have two client-side input radio buttons with javascript attached.
Clicking one hides one of two div's and vice versa.

The problem is that when I click an <asp: Buttonwhich fills a grid
the "checked" attribute on my input radio buttons gets reset to the
default value.

If I for example select radio button 2 I want it to be selected after
I've clicked the <asp: Button>.

How can I solve this problem?

Regards,

S

Jul 20 '06 #1
5 1483
If I for example select radio button 2 I want it to be selected after
I've clicked the <asp: Button>.

How can I solve this problem?
Make the radio buttons serverside controls.
Then set the values progammaticly on postback and do the logic serverside.
If you want to avoid a complete retransfer of the page you can use Ajax.

Jul 20 '06 #2
But I want to have the radio buttons client-side because it looks much
nicer when I can hide the div instantly without a server trip.
Mischa Kroon skrev:
If I for example select radio button 2 I want it to be selected after
I've clicked the <asp: Button>.

How can I solve this problem?

Make the radio buttons serverside controls.
Then set the values progammaticly on postback and do the logic serverside.
If you want to avoid a complete retransfer of the page you can use Ajax.
Jul 20 '06 #3
You can have both. Just add "runat=server" to the radio buttons html. It
will enable ViewState and the value will be preserved on round trips. And
keep your logic client-side.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

<st****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
But I want to have the radio buttons client-side because it looks much
nicer when I can hide the div instantly without a server trip.
Mischa Kroon skrev:
If I for example select radio button 2 I want it to be selected after
I've clicked the <asp: Button>.

How can I solve this problem?

Make the radio buttons serverside controls.
Then set the values progammaticly on postback and do the logic
serverside.
If you want to avoid a complete retransfer of the page you can use Ajax.

Jul 20 '06 #4

<st****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
But I want to have the radio buttons client-side because it looks much
nicer when I can hide the div instantly without a server trip.
2 simple options:

Add a clientside on click event to the control:
http://www.aspdev.org/articles/asp.n...dd.attributes/

Manipulate directly from javascript:
http://www.devx.com/tips/Tip/28332

Jul 20 '06 #5
Unfortunately none of this work. The default value is still reset.

Actually all I need to do is to run the javascript attached to radio
button 2 after the code attached to <asp:Buttonhas been executed. Is
that possible?
Mischa Kroon skrev:
<st****@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
But I want to have the radio buttons client-side because it looks much
nicer when I can hide the div instantly without a server trip.

2 simple options:

Add a clientside on click event to the control:
http://www.aspdev.org/articles/asp.n...dd.attributes/

Manipulate directly from javascript:
http://www.devx.com/tips/Tip/28332
Jul 20 '06 #6

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

Similar topics

7
2564
by: Tony Cooke | last post by:
Hi all. I'm not sure why I'm having problems with this but if I try to retrieve the value of a readonly text form I get back that the object is undefined. The reason the text is readonly is...
3
6718
by: Marty McFly | last post by:
Hello, I have a control class that inherits from System.Web.UI.WebControls.Button. When I drag this control from the "My User Controls" tab in the toolbox onto the form, I want it to reflect the...
2
3760
by: David P. Donahue | last post by:
I'm having a strange problem with a RadioButtonList (manually populated in the HTML, not data-bound) on one of my ASP .NET pages. I have the user select a value and click a button, then the...
6
2250
by: Joseph Geretz | last post by:
Writing an Outlook AddIn with C#. For the user interface within Outlook I'm adding matching pairs of Toolbar buttons and Menu items. All of the buttons and menu items are wired up to send events to...
1
3055
by: JJ | last post by:
I have two related problems: (a). trying to set the default button within a CreateUserWizard control ----------------------------------------------------------------- I've done this in a messy...
9
5035
by: Eric | last post by:
Hi Everyone, I'm writing a UserControl that exposes a property of the type System.Drawing.Image, like this: Public Property DefaultImage() As Image Get Return propDefaultImage End Get...
4
6117
by: rn5a | last post by:
I am binding a DropDownList with records existing in a database table. I want to add an extra item *SELECT COMPANY* at index 0 so that by default, it gets selected. This is how I tried it but the...
3
10782
by: remya1000 | last post by:
i'm using ASP with MSAccess as database. i have two buttons and two textbox in my page. when i press my first button (First month) i need to display the current month in one textbox and last one...
0
2773
by: thersitz | last post by:
Hi, Using aspnet3.5,VStudio 2008, VB 1.) I have a set of pages, with a search text box button within a userControl that searches across our websites and is registered in a masterpage. 2)...
0
7161
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
7384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7101
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
5686
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
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3234
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1596
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
802
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.