asma
asma

Reputation: 2845

Radiobutton Text alignment Issue

I am working in asp.net and have radiobutton list and I want to align their text as I require. Here is what I have currently:

enter image description here

I want to make them like this:

enter image description here

EDIT: Secondly, when I click Ages From radiobutton, I display a div against this like:

enter image description here

and when I click back to All Ages radio button, I want to hide that div. But SelectedIndexChanged doesn't work second time and onwards. It only works first time.

Code of aspx:

<table>
                        <tr>
                            <td>
                                <asp:RadioButtonList ID="rdoAge" runat="server" RepeatDirection="Horizontal" 
                                    onselectedindexchanged="rdoAge_SelectedIndexChanged" AutoPostBack="true" >
                                    <asp:ListItem Text="All Ages" Value="All Ages" Selected="True"></asp:ListItem>
                                    <asp:ListItem Text="Ages From" Value="Ages From"></asp:ListItem>
                                </asp:RadioButtonList>
                            </td>
                            <div id="divAge" runat="server" visible="false">
                                <td>
                                    <asp:TextBox ID="txtAgeFrom" runat="server" CssClass="textEntry2" MaxLength="3" Width="65"></asp:TextBox>
                                </td>
                                <td>
                                    <asp:Label ID="lblTo" runat="server" Text="To"></asp:Label>
                                </td>
                                <td>
                                    <asp:TextBox ID="txtAgeTo" runat="server" CssClass="textEntry2" MaxLength="3" Width="65"></asp:TextBox>
                                </td>
                            </div>
                        </tr>
                    </table>

Code of cs file:

protected void rdoAge_SelectedIndexChanged(object sender, EventArgs e)
    {
        switch (rdoAge.SelectedValue)
        {
            case "All Ages":
                divAge.Visible = false;
                break;
            case "Ages From":
                divAge.Visible = true;
                break;
        }
    }

I'll be grateful if anyone suggests something useful for this issue.

Thanks in advance.

Upvotes: 3

Views: 8514

Answers (3)

asma
asma

Reputation: 2845

That was the problem of missing closing tag. I must have missed a closing tag of some control. I re-added all controls with taking care of closing tags. Now it is working fine.

Thanks all for helping.

Upvotes: 1

thevan
thevan

Reputation: 10364

 switch (rdoAge.SelectedItem.Text)

In the Source Code, Define the Update Panel like this:

 <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">

and then in the OnSelectedIndexChanged event, add UpdatePanel1.Update();

Upvotes: 0

Pranay Rana
Pranay Rana

Reputation: 176956

try using css sytel

<style type="text/css">
 table.radioWithProperWrap input
 {    
      float: left;
 }

 table.radioWithProperWrap label
 {    
      word-wrap: break-word;

 }
</style>
<asp:RadioButtonList runat="server" CssClass="radioWithProperWrap" ....>

Upvotes: 0

Related Questions