my code looks something like this-:
<asp:RadioButtonList>
<asp:ListItem></asp:ListItem>
<asp:ListItem></asp:ListItem> //ToDo
<asp:ListItem></asp:ListItem>
</asp:RadioButtonList>
I want to show <asp:CheckBox> element after the second list item is selected.
So, the checkbox needs to appear between second and third list item. Is there anyway to do this?
Right now I'm showing the checkbox after the radiobuttonlist element.
That is not possible with a RadioButtonList. You will have to use single RadioButtons with GroupName to create your own.
<asp:RadioButton ID="RadioButton1" runat="server" GroupName="MyGroup" />
<asp:CheckBox ID="CheckBox1" runat="server" />
<asp:RadioButton ID="RadioButton2" runat="server" GroupName="MyGroup" />
<asp:RadioButton ID="RadioButton3" runat="server" GroupName="MyGroup" />
UPDATE
It is sort of possible in a hacky way. And if it is useful depends on what you want to do with that checkbox.
Make the Text of a ListItem a html checkbox.
RadioButtonList1.Items[1].Text = "<input type=\"checkbox\" id=\"checkBoxInsideList\" class=\"RadioButtonListWithCheckbox\">";
Then move it over the radio button
<style>
.RadioButtonListWithCheckbox {
margin-left: -16px;
}
</style>
Related
That's it, really. I have a DetailsView and a button on my ASP.NET page, and the button always appears beneath the DetailsView. Using floating DIVs breaks things in other ways, so is there any method to suppress the line break after the DetailsView, and have it display inline with the button?
I've tried applying Display:Inline CSS to the DetailsView, but it didn't work.
EDIT - CODE ADDED BELOW
<asp:DetailsView ID="dvPremisesYardName" runat="server" datasourceid="SQLGeneralDetails" DefaultMode="Edit" AutoGenerateRows="False" FieldHeaderStyle-CssClass="fieldtitleyardname"
GridLines="None" onchange="hideControl('imgGeneralDetailsTick');" >
<Fields>
<asp:TemplateField HeaderText="Yard Name">
<EditItemTemplate>
<asp:DropDownList ID="ddlPremisesYardName" runat="server" DataSourceID="SQLPremisesLookup" DataTextField="PremisesYardName" DataValueField="PremisesID" AutoPostBack="True"
SelectedValue='<%# Bind("AdmissionPremisesID")%>' AppendDataBoundItems="True" >
<asp:ListItem Text="Unknown" Value="" />
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
<asp:Button ID="btnPremisesAdd" runat="server" Text="Add New Premises" />
<asp:Button ID="btnPremisesEdit" runat="server" Text="Edit" />
As you stated, you do not want to use float div. The easiest way will be to use table.
Although we do not like to use table for page layout, I cannot think of other solution.
<table>
<tr>
<td><asp:DetailsView .../></td>
<td><asp:Button.../></td>
<td><asp:Button.../></td>
</tr>
</table>
Morning All,
I have a dropdown list that is populated by an SQLSataSource. I wish to make this dropdown list a required field and need to add add a default item like -Please Select- at the top of this list to prompt the user to make a selection.
Here is my code...
<asp:DropDownList ID="ddOwner" runat="server" DataSourceID="OwnersList"
DataTextField="UserFullName" DataValueField="UserFullName" Height="24px"
Width="125px">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvOwner"
ControlToValidate="ddOwner"
ErrorMessage="Please assign an Owner"
Text="*"
runat="server" Display="None"/>
Can i add some code into the 'Initial value' item to set the -Please select- default item?
Regards Betty
Add an unbound item:
<asp:DropDownList ID="ddOwner" runat="server" DataSourceID="OwnersList"
DataTextField="UserFullName" DataValueField="UserFullName" Height="24px"
AppendDataBoundItems="true"
Width="125px">
<asp:ListItem Text="-Please Select-" Value="" />
</asp:DropDownList>
You can try with after your DataBind Method
...
ddOwner.DataBind();
ddOwner.Items.Add("Please select- default item?");
I've created two radio buttons with the following code:
<telerik:RadButton ID="rbOption1" runat="server" Text="option 1" ToggleType="Radio"
GroupName="group1" ButtonType="ToggleButton" />
<br />
<telerik:RadButton ID="rbOption2" runat="server" ToggleType="Radio"
GroupName="group1" ButtonType="ToggleButton">
<ContentTemplate>
<asp:Label ID="lblChoose" runat="server" Text="choose" />
<asp:DropDownList ID="ddlChoose" runat="server" />
</ContentTemplate>
</telerik:RadButton>
I want the second radbutton to be rendered with a radio button just the the first radbutton. But instead the entire contents of the content template is being rendered as an html anchor and no radio button is being shown for the second radbutton. Is there a way to use the telerik radbutton to look like this mockup?
When the content of a RadButton is specified through the ContentTemplate inner property, the button control is automatically configured in a LinkButton mode.
The desired functionality can be achieved via two RadButtons, configured as radio buttons (ToggleType="Radio" ButtonType="ToggleButton"), and a DropDownList control that can be enabled only when one of the radio buttons is checked:
Page
<telerik:RadButton ID="rbOption1" runat="server" Text="option 1" ToggleType="Radio"
GroupName="group1" ButtonType="ToggleButton" />
<br />
<telerik:RadButton ID="rbOption2" runat="server" Text="choose" ToggleType="Radio"
GroupName="group1" ButtonType="ToggleButton" />
<asp:DropDownList ID="ddlChoose" runat="server" Enabled="false">
<asp:ListItem Text="Text" Value="Value"></asp:ListItem>
<asp:ListItem Text="Text" Value="Value"></asp:ListItem>
</asp:DropDownList>
<br />
Code-behind
protected void Page_Load(object sender, EventArgs e)
{
ddlChoose.Enabled = rbOption2.Checked;
}
I have an <asp:ComboBox> filled with <asp:CheckBoxes>. The Combobox is 200px wide. The Checkboxes are also 200px wide.
I can check the checkbox only if I click on 'box' or the checkbox text label. I want to be able to check the item even when I click anywhere on the row.
Is there any way to extend this area to the whole row?
update:
On the green area, everything is fine.
But on the red area when i click, checkbox is not checked and drop downlist goes up.
<telerik:RadComboBox runat="server" EnableTextSelection="false"
ID="rcb_Something"
Width="200px"
HighlightTemplatedItems="true"
AllowCustomText="true"
Text="Select Something"
MaxHeight="250px">
<ItemTemplate>
<telerik:RadBinaryImage ID="RadBinaryImage1" runat="server"
Width="24px"
Height="24px"
DataValue='<%# Eval("Something") %>'
ResizeMode="Fit" />
<asp:CheckBox ID="CheckBox1"
runat="server"
Text='<%# Eval("Something") %>'
ToolTip='<%# Eval("SomethingId") %>'
/>
</ItemTemplate>
Do as books say - add to every input field in HTML, a label tag with label.
<label for="male">Male</label> <input type="radio" name="sex" id="male" />
Clicking anywhere on label, will activate this input, same goes for input type=text
Ok, I find solution. I just disabled combobox background with following code.
JavaScript
function StopPropagation(e) {
//cancel bubbling
e.cancelBubble = true;
if (e.stopPropagation) {
e.stopPropagation();
}
}
aspx
<div onclick="StopPropagation(event)">
<asp:CheckBox ID="CheckBox1"
runat="server"
Text='<%# Eval("something") %>'
ToolTip='<%# Eval("somethingId") %>'
/>
</div>
How do I implement radio buttons in a grid view? I used asp:radiob button but the problem is that it selects all the radio buttons in the list. How do I select only one radio button at a time?
You can add the radio buttons in GridView using TemplateField.
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:RadioButton ID="rdoYes" runat="server" Text="Yes" Checked="true" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
You can select individual radio button if you added in GridView like above.
Make all the radio buttons part of a group by defing a GroupName for them.
Here is an example:
<html>
<body>
<form runat="server">
Select your favorite color:
<br />
<asp:RadioButton id="red" Text="Red" Checked="True"
GroupName="colors" runat="server"/>
<br />
<asp:RadioButton id="green" Text="Green"
GroupName="colors" runat="server"/>
<br />
<asp:RadioButton id="blue" Text="Blue"
GroupName="colors" runat="server"/>
<br />
<asp:Button text="Submit" OnClick="submit" runat="server"/>
<p><asp:Label id="Label1" runat="server"/></p>
</form>
</body>
</html>
If your going to use a grid view and u want to put a radio button on a TemplateField to act as a pointer to your selection just use this code on the rbSelector_CheckedChanged()...
protected void rbSelector_CheckedChanged(object sender, System.EventArgs e)
{
//Clear the existing selected row
foreach (GridViewRow oldrow in GridView1.Rows)
{
((RadioButton)oldrow.FindControl("rbSelector")).Checked = false;
}
//Set the new selected row
RadioButton rb = (RadioButton)sender;
GridViewRow row = (GridViewRow)rb.NamingContainer;
((RadioButton)row.FindControl("rbSelector")).Checked = true;
}
If theres any problem just let me know, ok? hope this code can help newbies out there like me.
Amit Patel
Use a TemplateField with a standard HTML control then on the codebehind use Request.Form.
ASPX:
<asp:TemplateField>
<ItemTemplate>
<input type="radio" name="group1" value='<%# Eval("YourValue") %>' />
</ItemTemplate>
</asp:TemplateField>
Codebehind:
string radioValue = Request.Form["group1"].ToString();