I am using radio buttons in my application is there any possible way to shift the text from the left side to right side
Asked
Active
Viewed 1.3k times
1
-
Have you tried like the way I posted the answer? – Sai Kalyan Kumar Akshinthala Oct 14 '11 at 12:59
-
yes the problem is When I click the content the button will not get selected – Mathew Paul Oct 14 '11 at 13:08
-
Are you using plain HTML? Make sure the label references the id of the radio button. Then the clicking on label will select the radio button. – Alex Duggleby Oct 14 '11 at 13:13
-
@Mathew Paul if you want to achieve like clicking on content, write some code to select radio button in the click event of label. – Sai Kalyan Kumar Akshinthala Oct 14 '11 at 13:13
-
@kalyan Yes Thanks Kalyan I am going to do something like that – Mathew Paul Oct 14 '11 at 13:16
-
@MathewPaul refer to the this http://stackoverflow.com/questions/181097/is-there-a-way-to-add-an-onclick-event-to-an-asp-net-label-server-control to get the Onclick event for a label – Sai Kalyan Kumar Akshinthala Oct 14 '11 at 13:22
1 Answers
6
Set the TextAlign
property to "Right" on the list it belongs to.
See here: http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.radiobuttonlist.textalign.aspx
Example (use a standard WebApplication in VS and include the following in default.aspx):
<asp:RadioButtonList id="RadioButtonList1"
RepeatDirection="Vertical"
RepeatLayout="Table"
TextAlign="Right"
runat="server">
<asp:ListItem>Item 1</asp:ListItem>
<asp:ListItem>Item 2</asp:ListItem>
<asp:ListItem>Item 3</asp:ListItem>
<asp:ListItem>Item 4</asp:ListItem>
<asp:ListItem>Item 5</asp:ListItem>
<asp:ListItem>Item 6</asp:ListItem>
</asp:RadioButtonList>
The result for setting TextAlign to Left is:

Alex Duggleby
- 7,948
- 5
- 37
- 44
-
@AlexDuggleby, but it will not change the radiobutton text from left to right side of the control – Sai Kalyan Kumar Akshinthala Oct 14 '11 at 12:54
-
Have to disagree, see expanded answer. Or am I misunderstanding something? – Alex Duggleby Oct 14 '11 at 13:09
-
@AlexDuggleby, he needs a functionality like "Text(righttothat)Radiocontrol" and not "Radiocontrol(lefttocontrol)Text" – Sai Kalyan Kumar Akshinthala Oct 14 '11 at 13:12
-
I tried with the above code again its displaying the text on the left hand side of the radiobutton – Mathew Paul Oct 14 '11 at 13:14
-
-
@MathewPaul Ok, please post your ASPX code/snippet, because if you paste that code into a clean VS project the result is as shown in the image. I'll try to help if I can see more of the code. Maybe there some JS/CSS getting in the way? – Alex Duggleby Oct 14 '11 at 13:18
-
@Alex When I give TextAlign to either Left or Right it is showing on the Left hand side of the Radio button – Mathew Paul Oct 14 '11 at 13:18
-
@Alex just now did it in a fresh page and found your answer as valid thanks for the answer I think there is some problem in the css file I will check it out Thanks once again – Mathew Paul Oct 14 '11 at 13:27
-
@AlexDuggleby, sorry for misunderstanding your code part. Its perfectly working. I am wrong actually. – Sai Kalyan Kumar Akshinthala Oct 15 '11 at 04:24