ItemsRequested() issue when response.flush

6 posts, 1 answers
  1. Robert
    Robert avatar
    199 posts
    Member since:
    Aug 2009

    Posted 21 Dec 2009 Link to this post

    We use a technique of flushing text to the browser to show a progress indicator on pages that take a while to load.
    We are basically sending html to display a GIF through the page_PreInit event as:

        Protected Sub Page_PreInit(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreInit
            Response.AddHeader("Refresh", Convert.ToString((Session.Timeout * 60) + 5))
            HttpContext.Current.Response.Buffer = True
            HttpContext.Current.Response.Write("<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.1//EN http://www.w3.org/tr/xhtml11/dtd/xhtml11.dtd'>")
            HttpContext.Current.Response.Write("<html xmlns='http://www.w3.org/1999/xhtml'>")
            HttpContext.Current.Response.Write("<div ID='divsplashScreen' runat='server'><table cellspacing='0' cellpadding='0' border='0' align='center'><tr><td class='copy' align='right' height='1'></td></tr><tr><td class='copyblack' style='font-family:tahoma;font-size:11px' align='center'><img src='images/progress.gif' border='0' align='absmiddle'><br></td></tr></table></div>")
            HttpContext.Current.Response.Write("</body></html>")
            HttpContext.Current.Response.Flush()
        End Sub

    For the most part this approach causes no problems. However with using the ItemsRequested() event for a ListBox on a page using this technique it fails.  the ItemRequested() event fires and does not generate an error although the list box is not being populated by the this event.  I am assuming that this is happening because the document is not well formed.  Basically sending anything to the document prior to the DOCTYPE causing the event to fail. 

    Can anyone think of a way around this?

    Robert

  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 21 Dec 2009 Link to this post

    Hello Robert,

    RadListtBox does not provide event named ItemsRequested. How exactly are you binding the listbox?

    Greetings,
    Genady Sergeev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. Robert
    Robert avatar
    199 posts
    Member since:
    Aug 2009

    Posted 21 Dec 2009 Link to this post

    Sorry I was going off of what I remembered about the issue.  It was the RadComboBox ... not ListBox.  My mistake

    This is adapted from the online demo.

    the one listbox is calling client function to load the other listbox.

    OnClientSelectedIndexChanging

     

    ="LoadSteps"

     


     

    function LoadSteps(combo, eventArqs)

     

    {

     

    var item = eventArqs.get_item();

     

     

    var cboSteps = $find("<%=cboCurrentStep.ClientID%>");

     

    cboSteps.set_text(

    "Loading...");

     

     

    // steps combobox passing pub cycle as parameter

     

    cboSteps.requestItems(item.get_value(),

    false);

     

    cboSteps.set_text(

    " All");

     



     

        Protected Sub cboCurrentStep_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles cboCurrentStep.ItemsRequested
            LoadSteps(e.Text)
        End Sub


     

        Protected Sub LoadSteps(ByVal sCycle As String)
            Dim conn As New SqlConnection(ConfigurationManager.ConnectionStrings("RTS_ConnectionString").ConnectionString)

            Dim Sql As String = " select anc.name as step, anp.name as parent "
            Sql += " ,ap.sequence_order, ac.sequence_order "
            Sql += "  from activities ap, "
            Sql += "  activities ac, "
            Sql += "  lookups lu, "
            Sql += "  activity_names anc, "
            Sql += " activity_names anp "
            Sql += " where ac.type_id = lu.lookup_id "
            Sql += " and  ac.name_id = anc.activity_name_id "
            Sql += " and  ac.parent_id = ap.activity_id "
            Sql += " and  ap.name_id = anp.activity_name_id "
            Sql += " and  lu.name = 'Step Template' "
            Sql += " and  anp.name=@sched "
            Sql += "  UNION SELECT ' All' as step, '' as parent,0,0 "
            Sql += " order by ap.sequence_order, ac.sequence_order "

            Dim adapter As New SqlDataAdapter(Sql, conn)
            adapter.SelectCommand.Parameters.AddWithValue("@sched", sCycle)

            Dim dt As New DataTable()
            adapter.Fill(dt)

            cboCurrentStep.DataTextField = "Step"
            cboCurrentStep.DataValueField = "Step"
            cboCurrentStep.DataSource = dt
            cboCurrentStep.DataBind()
        End Sub

  4. Robert
    Robert avatar
    199 posts
    Member since:
    Aug 2009

    Posted 23 Dec 2009 Link to this post

    Any idea of what I can do here?
  5. Answer
    Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 24 Dec 2009 Link to this post

    Hi Robert,

    When a RadComboBox requests its items, it invokes the page using a callback. Therefore, the Page property IsCallback is true. I suggest that you check for this property to be false before flushing the text into the browser. I have also noticed that in your LoadSteps method you use += to concatenate strings. However, this construction does not work in VB.NET and will produce a compile error. I suggest that you use the StringBuilder class to concatenate strings. It is faster and more reliable than simple &ing the strings.

    Best wishes,
    Genady Sergeev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  6. Robert
    Robert avatar
    199 posts
    Member since:
    Aug 2009

    Posted 30 Dec 2009 Link to this post

    Thanks... I had been do those Page.IsCallback checks in my other pages.  Somehow I overlooked it in this one.

    R
Back to Top