开发者

reserving a place for a radiobutton created dynamically in asp.net?

I am creating radiobuttons positioned horizontally, I am showing some and not showing others depending on some condition

If i set visible to false, the p开发者_开发百科lace will be occupied by the next radio button, is there any way of put space instead?

basic creation of radiobutton: (TEST only code)

                    Dim rdButton As New RadioButton
                    rdButton.Text = "test"
                    rdButton.GroupName = "test2"
                    cell.Controls.Add(rdButton)
                    Dim rdButton2 As New RadioButton
                    rdButton2.Text = "test2"
                    rdButton2.GroupName = "test2"
                    rdButton2.Visible=False
                    cell.Controls.Add(rdButton2) 
                    Dim rdButton3 As New RadioButton
                    rdButton3.Text = "test"
                    rdButton3.GroupName = "test2"
                    cell.Controls.Add(rdButton3)

thanks


You would use CSS Class to hide the radio button. To achieve this you can do something similar to this:

Css:

.radio-spacer {
visibility: hidden;
}

ASP.Net Controls:

<asp:RadioButton ID="RadioButton1" Text="Blue" GroupName="Hats"
 runat="server" />
<asp:RadioButton CssClass="radio-spacer" ID="RadioButton2" Text="Purple" 
 GroupName="Hats" runat="server" />
<asp:RadioButton ID="RadioButton3" Text="Orange" GroupName="Hats"
 runat="server" />

or Alternative (just Html):

<label>
<input type="radio" name="hatColour" value="blue" id="hatColour_0" />
Blue</label>
<label class="radio-spacer">
<input type="radio" name="hatColour" value="purple" id="hatColour_0" />
Purple</label>
<label>
<input type="radio" name="hatColour" value="orange" id="hatColour_1" />
Orange</label>

In the above example you will see 2 radio buttons (Blue and Orange) and you will see a spacer where Purple should be. You can test it here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜