Response.Write error

6 posts, 0 answers
  1. Naunton
    Naunton avatar
    70 posts
    Member since:
    Jun 2010

    Posted 11 Jan 2011 Link to this post

    Hi all,

    in RadAjaxManager1_AjaxRequest event I select data from database into reader, then if reader is Nothing i want to prompt alert
        Response.Write("<script>alert('There is no Data to show');</script>") .

    when I run alert didn't prompt, just got as below ...
    Error: Sys.WebForms.PageRequestmanagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the reponse is modified by calls to Reponse. Write(), reponse filters, httpModules, orserver trace is enabled.
    Detail: Error parsing near '<script> alert(' .

    How can I solve this please...

    Thanks and best regards
  2. Sebastian
    Admin
    Sebastian avatar
    9934 posts

    Posted 11 Jan 2011 Link to this post

    Hello naunt,

    Response.Write is not supported by RadAjax or the ASP.NET AJAX framework in general. To execute your custom alert, use either:
    • The Alert method of RadAjaxManager
      or
    • The RadAjaxManager's ResponseScripts collection/RegisterStartupScript method of the asp ScriptManager (see this topic for more info)
    Best regards,
    Sebastian
    the Telerik team
    Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Andy Green
    Andy Green avatar
    342 posts
    Member since:
    Aug 2008

    Posted 11 Jan 2011 Link to this post

    There should be no need to use response.write with dot net. Add a label control and just set the text value.

    Andy
  5. Naunton
    Naunton avatar
    70 posts
    Member since:
    Jun 2010

    Posted 11 Jan 2011 Link to this post

    Thanks admin ...

    RadAjaxManager1.Alert(), RadAjaxManager1.ResponseScripts are work very fine at RadAjaxManager1_AjaxRequest and button_click event.
    but for other control event is there any way to prompt alert?
    What I want to do is .. I have 3 combox and one listbox , one saveButton.
    At first pageload I will bind combox1 only. after select at combox1 will bind combox2, then after select combox2 bind combox3. finally after select combox3 will bind listbox.
    When select combox1 and bind to combox2 if there is no data for combox2 I want to tell user something, maybe Alert() or show with Label. combox2 also same.

    Recently how I do is.
    This is my first Combox
    <telerik:RadComboBox ID="CboPOL" runat="server"
            CssClass="label" Label="POL     :" Skin="Hay"
            OnClientSelectedIndexChanging="LoadVsl"
                OnItemsRequested="CboPOL_ItemsRequested"
                onclientitemsrequested="ItemsLoaded" ViewStateMode="Enabled"></telerik:RadComboBox>
    The script
    function LoadVsl(combo, eventArqs) {
                 var item = eventArqs.get_item();
                 VslCombo.set_text("Loading...");
                 VoyCombo.clearSelection();
     
                 if (item.get_index() > 0) {
                     VslCombo.requestItems(item.get_value(), false);
                 }
                 else {
                     VslCombo.set_text(" ");
                     VslCombo.clearItems();
     
                     VoyCombo.set_text(" ");
                     VoyCombo.clearItems();
                 }
             }
             function ItemsLoaded(combo, eventArqs) {
                 if (combo.get_items().get_count() > 0) {
                     // pre-select the first item
                     combo.set_text(combo.get_items().getItem(0).get_text());
                     combo.get_items().getItem(0).highlight();
                 }
    And code behind
    Protected Sub CboVsl_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles CboVsl.ItemsRequested
            LoadVsl(e.Text)
    End Sub
     
    Private Sub LoadVsl(ByVal pol As String)
            sQuery = "SELECT Distinct Vsl FROM [Table1] "
            Dim reader As SqlDataReader = SSLExecuteReader(sQuery, sqlD4ACon)
            If Not reader.HasRows Then
                'lblalert.Text = "<script>alert('There is no Data to show');</script>"
                'lblalert.Text = "*  There is no VesselCode!"
                'Response.Write("<script>alert('There is no Data to show');</script>")
                'RadAjaxManager1.Alert("There is no Data to show")
                RadAjaxManager1.ResponseScripts.Add(String.Format("alert('Show something {0}');", DateTime.Now.ToLongTimeString()))
             Else
                dt = New DataTable
                dt.Load(reader)
                CboVsl.DataTextField = "Vsl"
                CboVsl.DataValueField = "Vsl"
                CboVsl.DataSource = dt
                CboVsl.DataBind()
     
                CboVsl.Items.Insert(0, New RadComboBoxItem("- Select Vessel -"))
            End If

    I tried many way to show alert  ...
    even very simple way .. lblalert.Text = "*  There is no VesselCode!"  didn't show.
    Did I miss something ?
    Please help ..
  6. Vinkel
    Vinkel avatar
    36 posts
    Member since:
    Apr 2010

    Posted 12 Jan 2011 Link to this post

    You set your radcombo to be starter and updated of ajax request with radajaxmanagar setting? See the docs and demos how. lblAlert have also be updated to see text in it.

    -J
  7. Naunton
    Naunton avatar
    70 posts
    Member since:
    Jun 2010

    Posted 13 Jan 2011 Link to this post

    Hi Vinkel,

    1st combo and 2nd combo not use radajaxmanager(ajax_request not fire).
    At the 3rd combo I used radajaxmanager, at ajax_request event lblAlert was shown and radajaxmanager.alert() also work.

    Now what I want is for 1st combo and 2nd combo without using radajaxmanager and showing lblAlert.text="message here!". or is there any other way to show my message?
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017