Thanks for your followup.
Yes, in fact, I mentioned the RadioButton control just because we can use
multi RadioButton server controls on our page and register a single
eventhandler for their checkedChanged event. (No Autopostback needed), this
is a way of retrieving which one of those radio buttons is checked when
postback, RadioButton has a "GroupName" property just represent the "name"
attribute of the html <input type="radio" ...> element.
Well, if we still need to use the <input type="radio" ....> , there're also
a simple way to get the current selected value of a group of radio
elements. That's the Request.Form collection. As we know, all the html
input element's value will be post back to server side( when the page/form
is submited), these values are stored in the Request.Form collection as
name/value pairs. For those html input radios with the same "name"
attribute, the Request.Form["name"] just contains the currently checked
one's value. For example, if we have the following radio buttons on page:
<INPUT id="irOne" type="radio" name="cg" value="One" runat="server"> One
<INPUT id="irTwo" type="radio" name="cg" value="Two" runat="server"> Two
<INPUT id="irThree" type="radio" name="cg" value="Three" runat="server">
Three
<INPUT id="irFour" type="radio" name="cg" value="Four" runat="server"> Four
When postback, in the serverside code, we can use the below statement to
retreive the currently checked one's value:
string cgValue;
cgValue = Request.Form["cg"];
Hope helps. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: how do I determine which button is clicked with HTML
control?
| thread-index: AcWSc+yHpkREB3OATZadELa08DgpCA==
| X-WBNR-Posting-Host: 64.180.224.155
| From: =?Utf-8?B?U2FtdWVs?= <
[email protected]>
| References: <
[email protected]>
<
[email protected]>
| Subject: RE: how do I determine which button is clicked with HTML control?
| Date: Tue, 26 Jul 2005 23:25:03 -0700
| Lines: 32
| Message-ID: <
[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
| Xref: TK2MSFTNGXA01.phx.gbl
microsoft.public.dotnet.framework.aspnet.webcontrols:10103
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Thanks Steve for your response. Let me clarify a few things.
|
| 1) I was not going to use the RadioButton control, but the
RadiobuttonList
| control, like this
|
| <asp:RadioButtonList ID="deleteoption" runat="server"
| RepeatDirection="Horizontal">
| <asp:ListItem Value="deleteonly">Delete the file
| Only</asp:ListItem>
| <asp:ListItem Value="deleteandrun">Execute the
file,
| and if no error occurs, delete it.</asp:ListItem>
| </asp:RadioButtonList>
|
| 2) Because of the design requirement of the page, if I insist on using
the
| Radiobuttonlist, I will have a few other controls inside the
| <asp:RadioButtonList></asp:RadioButtonList> tags, which is not supported
at
| all. The RadioButtonList is not nested inside other controls.
|
| 3) I dont need to autopostback whenever a selection changes
|
| 4) I was wondering how I could determine which one of the radiobutton is
| selected on postback if I have the following grouped radio buttons (note
the
| values for the name attribute are the same, which means they are
grouped..):
|
| <input type="radio" name="group" value="1" runat="server">
| <input type="radio" name="group" value="2" runat="server">
| <input type="radio" name="group" value="3" runat="server">
|
| Typically you can check RadioButtonList1.SelectedItem.text if you use
| RadioButtonList, but in my case I can't.
|
| Please let me know your thought.
|