Web Forms :: Validate 2 Radiobuttonlist For At Least 1 ListItem Is Selected

Jul 22, 2010

I have 2 radiobuttonlist in a web forms, each contains of 4 ListItem. So there are 8 ListItems in total. It is initialised such that none of the ListItems is selected. I want to validate that at least one of the ListItems is selected when submit button is pressed. How to do it? i.e. at least 1 ListItem is selected, either from radiobuttonlist1 or radiobuttonlist2.

View 9 Replies


Similar Messages:

Web Forms :: Validate 2 Radiobuttonlist For At Least One ListItem Is Selected?

Jul 22, 2010

I have 2 radiobuttonlist in a web forms, each contains of 4 ListItem. So there are 8 ListItems in total. It is initialised such that none of the ListItems is selected. I want to validate that at least one of the ListItems is selected when submit button is pressed. How to do it? i.e. at least 1 ListItem is selected, either from radiobuttonlist1 or radiobuttonlist2.

View 4 Replies

Jquery - Set RadioButtonList First ListItem As Selected

Mar 8, 2011

I am using jquery and c# to dynamically set a radiobuttonlist listitem to selected. I want to create a reset-type button to reset the radiobuttonlist selected item back to the first item in the list. jQuery/jsTree function currently reseting textbox and hidden field:

$('#ContentPlaceHolder1_hfNodeID').val('');
$('.txtPage').val('');
$('.rblContentTypesGetAll').val();
$('.contentPageForm').show(),
.rblContentTypesGetAll is the radiobuttonlist i want to reset (or select the top most listitem).
HTML of the form:
<asp:Panel ID="PagesForm" CssClass="contentPageForm" runat="server">
<asp:HiddenField ID="hfNodeID" runat="server" Value="" />
<table>
<tr>
<td>Page</td>
<td><asp:TextBox ID="txtPage" CssClass="txtPage" runat="server" /><span class="validate">*</span><br />
<asp:RequiredFieldValidator ID="rfvPage" runat="server" CssClass="validate" ControlToValidate="txtPage" Display="Dynamic" ErrorMessage="Page Name Required" ValidationGroup="page" /></td>
</tr>
<tr>
<td>Content Type</td>
<td>
<asp:RadioButtonList id="rblContentTypesGetAll" CssClass="rblContentTypesGetAll" OnLoad="rblContentTypesGetAll_Load" runat="server" >
</asp:RadioButtonList>
</td>
</tr>
<tr>
<td> <asp:Button ID="Submit" runat="server" OnClick="PageSubmit_Click" Text="Save" ValidationGroup="page" />
<asp:Button ID="Cancel" runat="server" OnClick="Cancel_Click" Text="Cancel" />
</td>
</tr>
</table>
</asp:Panel>

View 2 Replies

AJAX :: RadioButtonList.SelectedIndexChanged Not Raised When The ListItem Has Selected="True" Not Working

Jun 29, 2010

I have two radiobuttons in radiobuttonlist and based on selection, i am enabling and disabling the text box.
First time i used date radiobutton and i took date in corresponding textbox and i saved it into database and then when i came back on same page i saw the date radiobutton is checked has proper value then i clicked on another radiobutton and this time page is postback and clear my all the data which was in my other controls(I have 5-6 text boxed on my page). I dont know why?, It supposed to select my other radiobutton and enable the corresponding text box

[Code]....

if (!Page.IsPostBack)
{
if (gvCredentialTypes.SelectedIndex >= 0)
{
CredentialType credType = CredentialType.FindCredentialType(gvCredentialTypes.SelectedValue.ToString());
if (!String.IsNullOrEmpty(credType.CredentialTypeName)) //If exists, load data
{
String expDays = credType.ExpirationLength.ToString();
DateTime expDate = Convert.ToDateTime(credType.ExpirationDate);
// Assign the value to the controls
LoadExpirationDaysDateValue(expDays, expDate);
}
}
}

private void LoadExpirationDaysDateValue(String expDays, DateTime expDate)
{
// Determines whether value for Days or Date is present
Boolean IsDays = false;
// Check if days value is present
if (String.IsNullOrEmpty(expDays) || expDays.Equals("0"))
{
txtExpirationDays.Text = String.Empty;
}
else
{
txtExpirationDays.Text = expDays;
IsDays = true;
}
if (expDate.ToShortDateString().Equals ("1/1/0001"))
{
txtExpirationDate.Text = String.Empty;
}
else
{
txtExpirationDate.Text = expDate.ToShortDateString();
IsDays = false;
}
// Set the radio button value based on whether Date or Days value is present
if (IsDays)
{
// Get ref to the 1st radio item
ListItem liExpirationInDays = rbExpiration.Items.FindByValue("rbExpirationInDays");
if (liExpirationInDays != null)
{
liExpirationInDays.Selected = true;
rbExpiration.Items.FindByValue("rbExpirationDate").Selected = false;
txtExpirationDate.Text = string.Empty;
txtExpirationDays.Text = expDays;
// Enable or disable the controls based on the radio button selection
txtExpirationDays.Enabled = true;
RequiredFieldValidator1.Enabled = true;
RangeValidator1.Enabled = true;
txtExpirationDate.Enabled = false;
RegularExpressionValidator1.Enabled = false;
CalendarExtender2.Enabled = false;
//compDateValidator.Enabled = false;
RequiredFieldValidator2.Enabled = false;
}
}
else
{
// Get ref to the 2nd radio item
ListItem liExpirationDate = rbExpiration.Items.FindByValue("rbExpirationDate");
if (liExpirationDate != null)
{
liExpirationDate.Selected = true;
rbExpiration.Items.FindByValue("rbExpirationInDays").Selected = false;
txtExpirationDays.Text = string.Empty;
txtExpirationDate.Text = expDate.ToShortDateString();
// Enable or disable the controls based on the radio button selection
txtExpirationDate.Enabled = true;
RegularExpressionValidator1.Enabled = true;
RequiredFieldValidator2.Enabled = true;
CalendarExtender2.Enabled = true;
//compDateValidator.Enabled = true;
txtExpirationDays.Enabled = false;
RequiredFieldValidator1.Enabled = false;
RangeValidator1.Enabled = false;
}
}
}

private void EnableCorrespondingTextbox()
{
switch (rbExpiration.SelectedItem.Value)
{
case "rbExpirationInDays":
txtExpirationDays.Enabled = true;
RequiredFieldValidator1.Enabled = true;
RangeValidator1.Enabled = true;
txtExpirationDate.Text = String.Empty;
txtExpirationDate.Enabled = false;
RegularExpressionValidator1.Enabled = false;
CalendarExtender2.Enabled = false;
RequiredFieldValidator2.Enabled = false;
//compDateValidator.Enabled = false;
break;
case "rbExpirationDate":
txtExpirationDate.Enabled = true;
RegularExpressionValidator1.Enabled = true;
RequiredFieldValidator2.Enabled = true;
CalendarExtender2.Enabled = true;
//compDateValidator.Enabled = true;
txtExpirationDays.Text = String.Empty;
txtExpirationDays.Enabled = false;
RequiredFieldValidator1.Enabled = false;
RangeValidator1.Enabled = false;
break;
}
}

protected void OnSelectedIndexChangedMethod(object sender, EventArgs e)
{
EnableCorrespondingTextbox();
}

View 4 Replies

Web Forms :: Can't Use Tags With RadioButtonList And ListItem?

Jan 11, 2010

I have a RadioButtonList with three ListItems, like this:

[Code]....

TrueRuleCondition, FalseRuleCondition, and CustomRuleCondition are protected constants in the code-behind file that I want to use as the values for my listitems. Unfortunately, the values get treated as literal values instead of having the values of the variables inserted. Does anyone know of a way to do this or why this doesn't work as I expect it to?

View 2 Replies

Add A Label To A RadioButtonList ListItem?

Mar 3, 2010

I have a RadioButtonList with two ListItems included:

<asp:RadioButtonList runat="server" ID="optRollover" OnSelectedIndexChanged="RolloverOptionSelected" AutoPostBack="true">
<asp:ListItem Value="0">100% </asp:ListItem>
<asp:ListItem Value="1">Less than 100%</asp:ListItem>
</asp:RadioButtonList><br />

On the first ListItem I need to have a label that displays some text from the code behind of the page. Logically it seems to me like I would be able to do something like this: 100% Obviously this does not work because I am getting an error: The 'Text' property of 'asp:ListItem' does not allow child objects.

View 1 Replies

Set ListItem Value To Constant For RadioButtonList In ASPX

Sep 23, 2010

I must be doing something wrong here but I can't find an easy way to get this to work. Imagine the following code:

<asp:RadioButtonList ID="MyRadioButtonList" runat="server">
<asp:ListItem Value="<%= CompanyName.SystemName.Constants.PaymentFrequency.FREQUENT.ToString() %>" Text="Yes" Selected="True"></asp:ListItem>
<asp:ListItem Value="<%= CompanyName.SystemName.Constants.PaymentFrequency.ONCE.ToString() %>" Text="No, Just do this once"></asp:ListItem>
</asp:RadioButtonList>

But it doesn't compile the statement before it renders the page. So if I get the selected value of this radiobuttonlist it contains something like "<%= Compan... %>" instead of what my constant defines.

View 1 Replies

RadioButtonList - Add The ListItem Values In The Code-behind Within A For Loop

Jan 27, 2011

Is it possible to add the ListItem values in the code-behind within a for loop? If so, what is it? Here is my current code:

rblContentTypesGetAll.Items.Clear();
for (int i = 0; i < dt.Rows.Count; i++)
{
rblContentTypesGetAll.Items.Add(dt.Rows[i]["contentType"].ToString());
}

View 1 Replies

Forms Data Controls :: Add ListItem Programatically With On Item Selected?

Jan 22, 2011

I have a DropDownList on my aspx page and wanted to add ListItem programatically. The item will start from 2 years ago to 1 year later (e.g. from 2009 to 2012) so if the year change, it will be automatic. I also want the current year to be selected by default.
In the code behind, I did this:

For i As Integer = (DateTime.Now.Year - 3) To (DateTime.Now.Year + 1)
DropDownList1.Items.Add(i.ToString())
Next
DropDownList1.SelectedItem.Text = DateTime.Now.Year

As result, I'm having the items in this order: 2011 (selected), 2009, 2010, 2011, 2012. The 2011 is duplicated (I wonder why). When I view the source page on Internet Explorer, I have this:

<option selected="selected" value="2011">2011</option>
<option value="2009">2009</option>
<option value="2010">2010</option>
<option value="2011">2011</option>
<option value="2012">2012</option>

View 2 Replies

Data Controls :: Set RadioButtonList Selected Value Based On GridView Selected Row?

May 7, 2015

how to display GridView Selected Row in dropdownlist and radiobutton outside GridView in ASP.Net?

View 1 Replies

Change The Default Color Of The Listitem Selected On A Listbox?

Jun 16, 2010

I have a listbox on the parameter selection page.

The .css style for the listbox is defined as:

.listBoxStyle
{
font-family: Arial, Verdana, Helvetica;
font-size: 100%;
text-align: right;
}

As a default, there is an item selected on the listbox. But the colour appears blue of the item selected. I want to change the colour of the selected item.

View 7 Replies

Validate Radiobuttonlist In A Gridview Using Javascript?

Feb 10, 2011

I am trying to validate that each radiobuttonlist has been selected. the radiobuttonlist is dynamically created from a sql database. The following line errors out "if (MyRadio[j].checked) {", the error is "checked' is null or not an object". The following is the code.

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder2" runat="Server">
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" CssClass="ajax__myTab" Width="100%" ScrollBars="Horizontal">
<cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="" Enabled="true">

[Code]....

View 1 Replies

Web Forms :: Get RadioButtonlist Selected Value?

Feb 8, 2010

i have wrote following code but it will not fecth selected value:

Table tab =
new Table();
int j = 0;

[code]...

View 4 Replies

Web Forms :: Submitting RadioButtonList Selected Value Into Database?

Dec 14, 2010

I have a web form(C#) which has many radiobuttonlist controls. For each control there is a corresponding field in a sql server database table. And finally there is a submit button.

How to send the selected values to the database?

View 7 Replies

Web Forms :: How To Add String In Radiobuttonlist Selected Item Text At The End

Jan 13, 2011

[Code]....
[Code]....
[Code]....

View 2 Replies

Web Forms :: Add Eventhandler To Radiobuttonlist Dynamically To Retrieve Selected Value?

Feb 24, 2010

A new route to an old problem for me... I'm creating radiobuttonlists and adding them to an update panel dynamically using this code:

[Code]....

I'm wanting to get the selected radio button value whenever a button on the page is pressed, however (and this is my old problem) I cannot retrieve that value. What I'm wanting to try is to add an event that will record the chosen radio button whenever the selected value has changed and store it into an array.

View 4 Replies

Forms Data Controls :: RadioButtonList Item Not Selected

Dec 22, 2010

Here is my .aspx page

[Code]....

and here is .cs file

TextBox TB_Fax = (TextBox)RegisterUserWizardStepDetails.FindControl("TB_Fax");

View 17 Replies

Forms Data Controls :: How To Get Radiobuttonlist Selected Value In A Repeater

Dec 21, 2010

how to get Radiobuttonlist selected value in a repeater

View 1 Replies

Web Forms :: Get Selected Value Of RadioButtonList Inside Repeater Control

Dec 23, 2013

I have added a RadioButtonList inside a repeater as follows:

(.aspx file):

<asp:Button ID="Button1" Text="Add Comment" runat="server" />
<asp:Panel ID="pnlPanelDemo" runat="server" CssClass="modalPopup" ViewStateMode="Disabled">
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</cc1:ToolkitScriptManager>
<asp:Repeater ID="rptComments" runat="server">

[Code] ....

Now suppose if 3 questions are displayed on the webpage then 3 radiobuttonlists are displayed. I need to send the selected text of radiobuttons separately in my table in SQL Server on a button click event.

Suppose if selected answers are Very Poor, Average and Good then database entry should look like:

1         Very Poor
2         Average
3         Good

(.aspx.cs file)

protected void AddComment(object sender, EventArgs e) {           
string constr = System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
string sqlStatment = "INSERT INTO FeedbackResponse(QUESTION_ID,RESPONSE) values(@QID,@RESP)"; 
using (SqlConnection con = new SqlConnection(constr)) { 
using (SqlCommand cmd = new SqlCommand(sqlStatment, con)) { 
con.Open();  cmd.Parameters.AddWithValue("@RESPONSE",this.rptComments.   
cmd.ExecuteNonQuery();  con.Close();               
} }

I am not sure what to do in the bold line.

View 1 Replies

Forms Data Controls :: ListItem Error Message Validation(ASP .Net):Attribute CssClass Is Not A Valid Attribute Of Element ListItem

Sep 17, 2010

I have a tag:

<asp:ListItem
CssClass="LabelCSS">Executive</asp:ListItem>

and I am getting the error message

Validation(ASP .Net):Attribute CssClass is not a valid attribute of element ListItem.

What attribute would I use for Css with ListItem?

View 2 Replies

Forms Data Controls :: Listbox Displays Value From Selected Radiobuttonlist?

Oct 30, 2010

listbox displays value from selected radiobuttonlist?

View 1 Replies

Forms Data Controls :: RadioButtonList, Gridview, TemplateColumn, Get Selected Radio Value In VB

Nov 28, 2010

[Code]....

VB.Net

[Code]....

RadioButtonList, Gridview, TemplateColumn, get selected radio value in VB

View 2 Replies

Forms Data Controls :: Selected Index Of Radiobuttonlist Inside A Repeater?

Dec 6, 2010

im having a quizz (a question and multiple answer related to the question) , i use an asp repeater to display the questionand a nested radiobuttonlist inside the item template for the related answer:

[Code]....

I do bind the the radiobutton on itemDatabound, i need to store the answer selected by the user, for that i used the following method:

[Code]....

but the rptAns referring to the radiobuttonlist (there is only one quiz at a time), the selectedindex always remain at the first index even when the user does change the selected radio button.i have made a check when on item databound to see if the page is a postback before opulating the radiobuttonlist.

View 3 Replies

Web Forms :: Is It Possible To Validate At Least 1 Is Selected

Sep 18, 2010

I have a form with several Drop Down List options, Is it possible to validate at least 1 is selected?

View 3 Replies

Forms Data Controls :: Selected Value Of RadioButtonList Inside A Formview Get Cleared On Button Click?

Sep 13, 2010

I placed a RadioButtonList inside a Formview control.And from DataBound event handler oformview ,RadioButtonList is binded to the datasource .Now my problem is after selecting a value from radiobuttonlist and I click any button,the radiobuttonList get unchecked and lose the selected value .How can I avoid this.

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved