473,672 Members | 2,676 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 1486
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=serv er" 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.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.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.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.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:Buttonha s been executed. Is
that possible?
Mischa Kroon skrev:
<st****@gmail.c omwrote in message
news:11******** **************@ h48g2000cwc.goo glegroups.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
2578
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 because it's a date which I set via a calendar javascript program (associated with a button) only so the user can't put something silly in requiring validation. The form send the data correctly when submitted it just doesn't seem to be
3
6750
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 following default properties: Height = 32px, Width = 144px. I declare the Width property in my control as... \\\
2
3768
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 code-behind's function for that button re-sorts a list based on the selected value. However, every postback results in the same sorting, and the RadioButtonList on the page always returns to the default value. Is there something else I need to be...
6
2261
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 the same method (aka delegate?). I use the Tag property within this method to determine what user action is taking place. Very simple: When adding toolbar button: tbButton.Click += new...
1
3062
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 way (see below) and wonder if anyone know how I could have done it using nested FindControl's and ClientID/UniqueID (I tried jst about every combination!) The button names you see in the code were obtained by viewing the source of the html...
9
5045
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 Set(ByVal Value As Image)
4
6131
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 extra item just doesn't get added to the DropDownList: ============================================= <script runat="server"> Sub Page_Load(..........) Dim dSet As DataSet Dim sqlConn As SqlConnection
3
10791
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 months date in another textbox. and while pressing the second button (submit) i need to display the date displayed in the textbox as itself and the records between thoses two dates. if that date is still there in the textbox only i can sort the...
0
2776
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) Also within that set of pages, I have a second, distinct seach box and button that searches a specific database that is within an asp:content area
0
8486
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8931
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8608
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7446
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4227
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4418
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2819
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 we have to send another system
2
2063
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1816
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.