Dynamic RadButton Issue

6 posts, 0 answers
  1. John
    John avatar
    4 posts
    Member since:
    Dec 2012

    Posted 10 Dec 2012 Link to this post

    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
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Dec 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. John
    John avatar
    4 posts
    Member since:
    Dec 2012

    Posted 10 Dec 2012 Link to this post

    Dear Shinu,

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

    John.
  5. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 10 Dec 2012 Link to this post

    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.
  6. John
    John avatar
    4 posts
    Member since:
    Dec 2012

    Posted 10 Dec 2012 Link to this post

    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

      
  7. Kevin
    Kevin avatar
    360 posts
    Member since:
    Jul 2012

    Posted 11 Dec 2012 Link to this post

    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.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017