This is a migrated thread and some comments may be shown as answers.

Dynamic RadButton Issue

5 Answers 121 Views
Button
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 10 Dec 2012, 09:19 AM
Hi,

I am dynamically creating radButton and Setting ButtonToggleType is radio and then Adding to the Pannel.But the problem is radButton is not showing like a radio button but shown as a normal button. Kindly look at my code and attachment and advise me to rectify the issue. Thanks in advance.

John.

For Each objChannel As TranChannel In _alChannels
              Dim RadButton1 As New RadButton()
              RadButton1.ID = objChannel.TranChannelCode
              RadButton1.Text = objChannel.Description
              RadButton1.Width = "100"
              RadButton1.ToggleType = ButtonToggleType.Radio
              RadButton1.ButtonType = RadButtonType.StandardButton
              RadButton1.GroupName = "StandardButton"
              Dim RadButtonToglle As New RadButtonToggleState()
              RadButtonToglle.Text = objChannel.Description
              RadButtonToglle.PressedCssClass = "rbToggleRadioChecked"
              RadButton1.ToggleStates.Add(RadButtonToglle)
              Dim RadButtonToglle1 As New RadButtonToggleState()
              RadButtonToglle1.Text = objChannel.Description
              RadButtonToglle1.PressedCssClass = "rbToggleRadio"
              RadButton1.ToggleStates.Add(RadButtonToglle1)
              AddHandler RadButton1.Click, AddressOf RadButton1_Click
              pnlRadio.Controls.Add(RadButton1)
          Next

5 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 10 Dec 2012, 10:09 AM
Hi John,

After inspecting your code I found that you are setting the ButtonType of RadButton as StandardButton. Please make sure that you are setting the ButtonType of RadButton as ToggleButton to show a RadioButton.

VB:
RadButton1.ButtonType = RadButtonType.ToggleButton

Regards,
Shinu.
0
John
Top achievements
Rank 1
answered on 10 Dec 2012, 10:23 AM
Dear Shinu,

Thanks for your reply.Kindly look at attached files where you can see my current behavior and expected behavior.

John.
0
Shinu
Top achievements
Rank 2
answered on 11 Dec 2012, 04:08 AM
Hi John,

Try the following code snippet.

VB:
For Each objChannel As TranChannel In _alChannels
              Dim RadButton1 As New RadButton()
              RadButton1.ID = objChannel.TranChannelCode
              RadButton1.Text = objChannel.Description
              RadButton1.Width =  Unit.Pixel(100)
              RadButton1.ToggleType = ButtonToggleType.Radio
              RadButton1.ButtonType = RadButtonType.ToggleButton
              RadButton1.GroupName = "StandardButton"
              Dim RadButtonToglle As New RadButtonToggleState()
              RadButtonToglle.Text = objChannel.Description
              RadButtonToglle.PressedCssClass = "rbToggleRadioChecked"
              RadButton1.ToggleStates.Add(RadButtonToglle)
              Dim RadButtonToglle1 As New RadButtonToggleState()
              RadButtonToglle1.Text = objChannel.Description
              RadButtonToglle1.PressedCssClass = "rbToggleRadio"
              RadButton1.ToggleStates.Add(RadButtonToglle1)
              AddHandler RadButton1.Click, AddressOf RadButton1_Click
              pnlRadio.Controls.Add(RadButton1)
Next

Regards,
Shinu.
0
John
Top achievements
Rank 1
answered on 11 Dec 2012, 05:25 AM
Hi Shinu,

Thanks for your code snippet. by applying the advised code, the effcet of radio button , you can see the attached file called Current behaviour_01. But I expect the behaviour of radio button like attached file Expected behaviour.If I place a control is design it is working fine. when i create a control dynamically, I am facing an issue.kindly help. Thank you.

John

  
0
Kevin
Top achievements
Rank 2
answered on 11 Dec 2012, 05:01 PM
Hello John,

That is the expected rendering when using ToggleButton and Radio Button together. The closest I can get to that button style is using the LinkedButton appearance. If that's alright with you, you could add the following to you RadButton's.

RadButton.CssClass = "rbLinkButton";

I tried with the normal button skin class, but it doesn't work with the rendering that is outputted when using the ToggleButton type.

I hope that helps.
Tags
Button
Asked by
John
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
John
Top achievements
Rank 1
Kevin
Top achievements
Rank 2
Share this question
or