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

Response.Write error

5 Answers 430 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Naunton
Top achievements
Rank 1
Naunton asked on 11 Jan 2011, 10:36 AM
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

5 Answers, 1 is accepted

Sort by
0
Sebastian
Telerik team
answered on 11 Jan 2011, 12:04 PM
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.
0
Andy Green
Top achievements
Rank 2
answered on 11 Jan 2011, 02:07 PM
There should be no need to use response.write with dot net. Add a label control and just set the text value.

Andy
0
Naunton
Top achievements
Rank 1
answered on 12 Jan 2011, 04:03 AM
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 ..
0
Vinkel
Top achievements
Rank 1
answered on 12 Jan 2011, 01:02 PM
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
0
Naunton
Top achievements
Rank 1
answered on 13 Jan 2011, 06:24 AM
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?
Tags
General Discussions
Asked by
Naunton
Top achievements
Rank 1
Answers by
Sebastian
Telerik team
Andy Green
Top achievements
Rank 2
Naunton
Top achievements
Rank 1
Vinkel
Top achievements
Rank 1
Share this question
or