473,545 Members | 2,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Radio Button Hell

Hi,

I have a some radio buttons on a aspx page that cause a post back. I
need to get the checked status in the page_init event handler. However
it seems that the checked status is only updated after the page_init
event. Any way I can get arround this?

I'll give a quick example in C#. These two methods are fired when I
check the radio button radioBtnExample

void Page_Init(Objec t sender, EventArgs e)
{
// false here
bool buttonState = radioBtnExample .Checked;

SetUpDataGridCo lumns(buttonSta te);
}

private void radioBtnExample _CheckedChanged (object sender,
System.EventArg s e)
{
// true here
bool buttonState = radioBtnExample .Checked;

BindDataToDataG rid(buttonState );
}

Any help would be most welcome

Dominic Godin
Nov 18 '05 #1
6 1871
Hi,
the values will be filled in only after Init event. So you can access the
values only after init. You can put the same code in page load to get the
values.
Hope this may solve.
Jagadeesh
"Dominic Godin" <nospam@plz> wrote in message
news:Xn******** *************** @207.46.248.16. ..
Hi,

I have a some radio buttons on a aspx page that cause a post back. I
need to get the checked status in the page_init event handler. However
it seems that the checked status is only updated after the page_init
event. Any way I can get arround this?

I'll give a quick example in C#. These two methods are fired when I
check the radio button radioBtnExample

void Page_Init(Objec t sender, EventArgs e)
{
// false here
bool buttonState = radioBtnExample .Checked;

SetUpDataGridCo lumns(buttonSta te);
}

private void radioBtnExample _CheckedChanged (object sender,
System.EventArg s e)
{
// true here
bool buttonState = radioBtnExample .Checked;

BindDataToDataG rid(buttonState );
}

Any help would be most welcome

Dominic Godin

Nov 18 '05 #2
Hi,

Dosn't help. The SetUpDataGridCo lumns(buttonSta te) must be run in the
init to work properly. Any body else no a way round this?

Dominic Godin
"jagadeesh" <ja************ ***@hotmail.com > wrote in
news:Ol******** ******@tk2msftn gp13.phx.gbl:
Hi,
the values will be filled in only after Init event. So you can access
the values only after init. You can put the same code in page load to
get the values.
Hope this may solve.
Jagadeesh
"Dominic Godin" <nospam@plz> wrote in message
news:Xn******** *************** @207.46.248.16. ..
Hi,

I have a some radio buttons on a aspx page that cause a post back. I
need to get the checked status in the page_init event handler.
However it seems that the checked status is only updated after the
page_init event. Any way I can get arround this?

I'll give a quick example in C#. These two methods are fired when I
check the radio button radioBtnExample

void Page_Init(Objec t sender, EventArgs e)
{
// false here
bool buttonState = radioBtnExample .Checked;

SetUpDataGridCo lumns(buttonSta te);
}

private void radioBtnExample _CheckedChanged (object sender,
System.EventArg s e)
{
// true here
bool buttonState = radioBtnExample .Checked;

BindDataToDataG rid(buttonState );
}

Any help would be most welcome

Dominic Godin



Nov 18 '05 #3
The problem is that you're starting off with the wrong assumption ("I need
to get the checked status in the page_init event handler"). You DON'T need
to get the checked status in the page_init event handler. You DO need to
fulfill the requirements of your application, which doesn't dictate HOW you
fulfill those requirements. The architecture of ASP.Net dictates how you
fulfill those requirements. Here is a link to an outline of the
System.Web.UI.C ontrol Execution Lifecycle. If you work with it as intended,
you should have no problem:

http://msdn.microsoft.com/library/de...nLifecycle.asp

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Dominic Godin" <nospam@plz> wrote in message
news:Xn******** *************** @207.46.248.16. ..
Hi,

I have a some radio buttons on a aspx page that cause a post back. I
need to get the checked status in the page_init event handler. However
it seems that the checked status is only updated after the page_init
event. Any way I can get arround this?

I'll give a quick example in C#. These two methods are fired when I
check the radio button radioBtnExample

void Page_Init(Objec t sender, EventArgs e)
{
// false here
bool buttonState = radioBtnExample .Checked;

SetUpDataGridCo lumns(buttonSta te);
}

private void radioBtnExample _CheckedChanged (object sender,
System.EventArg s e)
{
// true here
bool buttonState = radioBtnExample .Checked;

BindDataToDataG rid(buttonState );
}

Any help would be most welcome

Dominic Godin

Nov 18 '05 #4
Hi,

Interesting article thanks. I will have to think a little more when
designing pages after reading that.

Got it working. Seems that I have to reload the page twice to get data
into the init.

The page loads once on the postback, gets to the event where I set a
session var and reload the page. The init then checks for this session
var.

Dominic Godin

"Kevin Spencer" <ks******@takem pis.com> wrote in
news:eg******** ******@TK2MSFTN GP10.phx.gbl:
The problem is that you're starting off with the wrong assumption ("I
need to get the checked status in the page_init event handler"). You
DON'T need to get the checked status in the page_init event handler.
You DO need to fulfill the requirements of your application, which
doesn't dictate HOW you fulfill those requirements. The architecture
of ASP.Net dictates how you fulfill those requirements. Here is a link
to an outline of the System.Web.UI.C ontrol Execution Lifecycle. If you
work with it as intended, you should have no problem:

http://msdn.microsoft.com/library/de...l=/library/en- us/cpguid e/html/cpconControlExe cutionLifecycle .asp

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.


Nov 18 '05 #5
You can do a Request.Form["id"] and get the values. I think the Request is
loaded by Init. This really isn't asp.net functionality, but it will get
your desired result.

What are you doing that you can't do this from Page_Load?

bill

"Dominic Godin" <nospam@plz> wrote in message
news:Xn******** *************** @207.46.248.16. ..
Hi,

Dosn't help. The SetUpDataGridCo lumns(buttonSta te) must be run in the
init to work properly. Any body else no a way round this?

Dominic Godin
"jagadeesh" <ja************ ***@hotmail.com > wrote in
news:Ol******** ******@tk2msftn gp13.phx.gbl:
Hi,
the values will be filled in only after Init event. So you can access
the values only after init. You can put the same code in page load to
get the values.
Hope this may solve.
Jagadeesh
"Dominic Godin" <nospam@plz> wrote in message
news:Xn******** *************** @207.46.248.16. ..
Hi,

I have a some radio buttons on a aspx page that cause a post back. I
need to get the checked status in the page_init event handler.
However it seems that the checked status is only updated after the
page_init event. Any way I can get arround this?

I'll give a quick example in C#. These two methods are fired when I
check the radio button radioBtnExample

void Page_Init(Objec t sender, EventArgs e)
{
// false here
bool buttonState = radioBtnExample .Checked;

SetUpDataGridCo lumns(buttonSta te);
}

private void radioBtnExample _CheckedChanged (object sender,
System.EventArg s e)
{
// true here
bool buttonState = radioBtnExample .Checked;

BindDataToDataG rid(buttonState );
}

Any help would be most welcome

Dominic Godin


Nov 18 '05 #6
I have a data grid that shows a data table. There are some radio buttons
that will change the data table displayed. When they click the radio
button I build the boundColumns and add them to the datagrid. This can
only be done in the init for the columns to work properly.

I have it working now. Just had to take a different approach.

Dominic Godin
"William F. Robertson, Jr." <wfrobertson_at _kpmg_dot_com> wrote in
news:OG******** *****@tk2msftng p13.phx.gbl:
You can do a Request.Form["id"] and get the values. I think the
Request is loaded by Init. This really isn't asp.net functionality,
but it will get your desired result.

What are you doing that you can't do this from Page_Load?

bill


Nov 18 '05 #7

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

Similar topics

4
3261
by: Oscar Monteiro | last post by:
I Have to sets of Radio buttons like so: <input type="radio" name=p1 value=1> <input type="radio" name=p1 value=2> <input type="radio" name=p1 value=3> <br> <input type="radio" name=p2 value=1> <input type="radio" name=p2 value=2> <input type="radio" name=p2 value=3> then a text area and a button:
5
3082
by: Digital Puer | last post by:
I have the following HTML form: - radio button A (default selected) - radio button B - input field, of type "file" with "Choose" button - submit button I would like to have it so that if the user clicks on the "Choose" button of the input field (to select a file on the local disk), then radio button B is automatically
3
3108
by: John Davis | last post by:
I created a ASP.NET Web Form using VB.NET with a text box, 2 radio buttons. When the user click the first radio button, the text will change to uppercase. If the user clicks the other radio button, the text will change to lowercase. I added the following event, but still won't able to change the text to uppercase. Private Sub...
3
2060
by: Amelyan | last post by:
When we want radio button to belong to a group name we say, radio1.GroupName="GroupA". In this case, radio1 will be unselected if another radio button is selected in "GroupA". Is there a way (trick, custom RadioButton, or javascript) to make radio button (radio1) belong to 2 independent radio button groups instead of one? This would be an...
8
5891
by: David Cameron | last post by:
I noticed that using an HTMLInputRadioButton and specifying a value to be an empty string (""), this is overridden by ASP.Net which set the value of the control to be the same as the ID of the control. See the code below * Page.aspx: <%@ Page language="c#" Codebehind="Test.aspx.cs" AutoEventWireup="false" Inherits="Webspace.Test" %>
9
2224
by: IchBin | last post by:
I can not see what the problem is with this script. I am just trying to set a radio button by calling setCheckedValue('abbr_letter', 'V'). Sorry I am new to javascript. <html> <head> <script type="text/javascript"> function setCheckedValue(radioObj, newValue) { if(!radioObj)
10
6056
by: IchBin | last post by:
I am trying to set the state of a radio button. I do not see what I am doing wrong. Sorry, I am new at this.. I need another set of eyes to look at this snip of code. I am trying to set the radio button with this link of code: echo 'SCRIPT language=JavaScript setCheckedValue("'.$_SESSION.'");</SCRIPT>'; //? <snip of code>
3
2303
by: Chris Marsh | last post by:
Hello, Is it possible w/ASP.Net to set the property of the radio button control to 'read-only' after the user has made their selection before hitting an 'submit' button? Think of a multiple choice question, in our case it's 'Accept', 'Not Accept' or 'Pending' in a grid column. There are multple rows in the grid maybe 2, 3 or even 10 rows...
8
4599
by: photoboy | last post by:
I have racked by brain long enough on this, so now I need the help of someone who knows what they are doing. Here is what I am trying to achieve: First, I have two radio buttons (both unchecked) that need to be validated when the submit button is clicked. Instead of the standard alert window popping up (which I have now), I want the radio...
0
7484
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...
0
7675
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. ...
0
7928
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7440
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...
0
5997
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...
0
3470
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...
0
3451
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1902
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
1
1030
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.