Load on demand using webservice issue

2 posts, 0 answers
  1. Samir
    Samir avatar
    8 posts
    Member since:
    Jul 2009

    Posted 28 Oct 2010 Link to this post

      I am using webservice to return items similar to demo. I need to have radio buttons in the items that postbacks. So i am dynamically creating radiobuttonlist and listitems in the getrotatoritems function in the webservice and since item can only return pure client html, i am using htmltextwriter to render the radiobuttonlist into string and attaching that to item.Html property. The issue i am having is htmltextwriter is loosing the autopostback property of the radiobuttonlist, so even though i am setting autopostback = true, its not posting back. Did i miss anything?? Or is there any workaround for this?

  2. Fiko
    Fiko avatar
    1406 posts

    Posted 03 Nov 2010 Link to this post

    Hello Samir,

    I have already answered your support ticket. For convenience I have pasted my reply here as well:

    "The problem that you experience is not directly related to RadRotator control. The issue is caused by the fact that the RadioButton's properties are not rendered by the RenderControl method. You can manually add some attributes, however, by using the ListItem's Attributes property.
    Private Function GetRadioButtonList() As String
        Dim radioList As New RadioButtonList()
        radioList.ID = "RadioButtonList1"
        Dim item1 As New ListItem("Item1", "Item1")
        Dim item2 As New ListItem("Item2", "Item2")
        Dim item3 As New ListItem("Item3", "Item3")
        item1.Attributes.Add("onclick", "onRadioClickHandler(this);")
        item2.Attributes.Add("onclick", "onRadioClickHandler(this);")
        item2.Attributes.Add("onclick", "onRadioClickHandler(this);")
        Dim sw As New StringWriter()
        Dim writer As New HtmlTextWriter(sw)
        Return sw.ToString()
    End Function

    Then you can assign the returned HTML by the GetRadioButtonList method to the RadRotatorItemData.Html property:
    Private maxItemsCount As Integer = 3
    Private itemCount As Integer = 1
    <WebMethod> _
    Public Function GetRotatorData(itemIndex As Integer) As RadRotatorItemData()
        If itemIndex >= maxItemsCount Then
            Return Nothing
        End If
        Dim result As New List(Of RadRotatorItemData)()
        For i As Integer = itemIndex To itemIndex + (itemCount - 1)
            Dim item As New RadRotatorItemData()
            item.Html = Me.GetRadioButtonList()
        Return result.ToArray()
    End Function

    onRadioClickHandler JavaScript handler should be declared on the page which hosts the RadRotator control:

    <head runat="server">
        <style type="text/css">
        <script type="text/javascript">
            function onRadioClickHandler(clickedButton)
                // Use AjaxPanel to call server-side method
    <body class="BODY">
        <form id="Form1" method="post" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <telerik:RadRotator ID="RadRotator1" runat="server" Width="100" ItemWidth="100"Height="100"
            <WebServiceSettings Path="RotatorWebService.asmx" Method="GetRotatorData"/>

    Best wishes,
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top