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

ItemsRequested() issue when response.flush

5 Answers 146 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 21 Dec 2009, 03:32 PM
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

5 Answers, 1 is accepted

Sort by
0
Genady Sergeev
Telerik team
answered on 21 Dec 2009, 05:58 PM
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.
0
Robert
Top achievements
Rank 1
answered on 21 Dec 2009, 06:09 PM
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

0
Robert
Top achievements
Rank 1
answered on 23 Dec 2009, 06:27 PM
Any idea of what I can do here?
0
Accepted
Genady Sergeev
Telerik team
answered on 24 Dec 2009, 03:31 PM
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.
0
Robert
Top achievements
Rank 1
answered on 30 Dec 2009, 09:03 PM
Thanks... I had been do those Page.IsCallback checks in my other pages.  Somehow I overlooked it in this one.

R
Tags
ListBox
Asked by
Robert
Top achievements
Rank 1
Answers by
Genady Sergeev
Telerik team
Robert
Top achievements
Rank 1
Share this question
or