Hi All,
Am facing the problem with ajax implementation in Telerik Rad Grid.
In my page i implement RadAjaxmanager and RadAjaxPanel and RadGrid. Inside RadGrid. I want to edit details so am using EditFormSettings to edit details. In this EditFormSettings am calling a user control form.
My problem is, i dont want to allow unsafe script inside my edit form.
Am facing the problem with ajax implementation in Telerik Rad Grid.
In my page i implement RadAjaxmanager and RadAjaxPanel and RadGrid. Inside RadGrid. I want to edit details so am using EditFormSettings to edit details. In this EditFormSettings am calling a user control form.
My problem is, i dont want to allow unsafe script inside my edit form.
- So i turn on in web config file <%@ page Validate Request=True %>
- If user enters unsafe script in any text box am catching exception in my Global application_error event and redirecting to another normal aspx page.
- if i use RadGrid and Update details i use <EditFormSettings UserControlName="~/editform.ascx" EditFormType="WebUserControl" >. And i type any unsafe script message "<b>example</b>" inside the textbox.
Error was capturing in Global.aspx file, But not redirecting to Error page and throwing a javasscript error
Codes am using
- My Web config code :
<pages validateRequest="true"> Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs) Dim ex As Exception = Server.GetLastError().GetBaseException() If Not (ex.GetType Is GetType(HttpException)) Then If ex.Message.ToLower.Contains("a potentially dangerous request.form value was detected from the client") Then Try My.Log.WriteEntry("Global Error MESSAGE: " & ex.Message & "SOURCE: " & ex.Source & "STACKTRACE: " & ex.StackTrace, EventLogEntryType.Error) Catch ex1 As Exception My.Log.WriteEntry("Write event log got problem: " & ex1.Message, EventLogEntryType.Error) End Try Server.Transfer("~/UnsafeScriptErrorPage.aspx?returnURL=" & Server.UrlEncode(HttpContext.Current.Request.Url.ToString)) ElseIf ex.Message.Trim.ToString <> "" Then Try My.Log.WriteEntry("Global Error MESSAGE: " & ex.Message & "SOURCE: " & ex.Source & "STACKTRACE: " & ex.StackTrace, EventLogEntryType.Error, False) Catch ex1 As Exception My.Log.WriteEntry("Write event log got problem: " & ex1.Message, EventLogEntryType.Error) End Try Server.Transfer("~/GenericErrorPage.aspx?errMsg=" & ex.Message & "&returnURL=" & Server.UrlEncode(HttpContext.Current.Request.Url.ToString), False) End If End If Server.ClearError() End Sub
My First ASPX Code -
<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Inbox.aspx.vb" Inherits="Inbox" Title="Inbox" %> <%@ Register assembly="RadAjax.Net2" namespace="Telerik.WebControls" tagprefix="radA" %> <%@ Register src="../datagridControl.ascx" tagname="datagridControl" tagprefix="uc1" %> <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server"> <radA:RadAjaxPanel ID="RadAjaxPanelAppIn" runat="server" LoadingPanelID="AjaxLoadingPanelAppin" ClientEvents-OnRequestStart="pnlRequestStarted" Width="100%"> <table border="0" cellpadding="0" cellspacing="0" class="HeaderBg" width="100%"> <tbody> <tr> <td class="SideSpaceWidth"> </td> <td class="SideSpaceHeight"> <radA:AjaxLoadingPanel ID="AjaxLoadingPanelAppin" runat="server" IsSticky="True" MinDisplayTime="1000" Wrap="False"> <asp:Image ID="Image1" runat="server" AlternateText="Loading..." ImageUrl="~/images/indicator.gif" /> <strong>Loading Content ...</strong></radA:AjaxLoadingPanel> </td> <td class="SideSpaceWidth"> </td> </tr> <tr> <td > </td> <td> <uc1:datagridControl ID="DatagridControl1" runat="server" /> </td> <td> </td> </tr> <tr> <td> </td> <td class="SideSpaceHeight"> </td> <td> </td> </tr> </tbody> </table> </radA:RadAjaxPanel> </asp:Content> -
<radG:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True" AllowFilteringByColumn="False" AllowMultiRowSelection="false" AllowPaging="True" AllowSorting="True" BackColor="Transparent" DataSourceID="GridDataSource" EnableAJAX="false" EnableAJAXLoadingTemplate="false" EnableViewState="true" GridLines="None" LoadingTemplateTransparency="50" ShowGroupPanel="True" ShowStatusBar="False" AutoGenerateColumns="true" OnUpdateCommand="RadGrid1_UpdateCommand" SkinID="myGrid" OnColumnCreated="ColumnCheck" OnPreRender="ReduceFilter" Width="100%" OnItemDataBound="ColDatabind"> <MasterTableView DataSourceID="GridDataSource" GroupLoadMode="Client"> <Columns> <radG:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="~/Images/edit.gif" UniqueName="EditCommandColumn1" Resizable="False" Reorderable="False"> <HeaderStyle Width="15px" /> </radG:GridEditCommandColumn> <radG:GridTemplateColumn UniqueName="AssignUser" AllowFiltering="False" Reorderable="False" Groupable="False" Resizable="False" Visible="false"> <HeaderStyle Width="20px" /> <HeaderTemplate /> <ItemTemplate> <asp:ImageButton runat="Server" ID="ibtnAssignMsg" ImageUrl="~/images/Asgn.gif" CommandName="AssignMsgToUser" ToolTip="Assign SMS to User" Visible="false" /> </ItemTemplate> </radG:GridTemplateColumn> <radG:GridTemplateColumn UniqueName="myselect" AllowFiltering="False" Reorderable="False" Groupable="False" Resizable="False"> <HeaderStyle Width="20px" /> <HeaderTemplate> <asp:CheckBox ID="selectall" runat="Server" OnLoad="SelectAll" /> </HeaderTemplate> <ItemTemplate> <asp:CheckBox runat="Server" ID="myselect" OnLoad="ClearSAll" /> </ItemTemplate> </radG:GridTemplateColumn> </Columns> <EditFormSettings UserControlName="~/editform.ascx" EditFormType="WebUserControl" > <EditColumn UniqueName="EditCommandColumn"> </EditColumn> </EditFormSettings> <NoRecordsTemplate> <table width="100%"> <tr> <td align="center"> There are no items to display. Please check your selection criteria and retry. </td> </tr> </table> </NoRecordsTemplate> <FooterStyle Height="0px" /> <ExpandCollapseColumn Visible="False"> <HeaderStyle /> </ExpandCollapseColumn> <RowIndicatorColumn Visible="False"> <HeaderStyle /> </RowIndicatorColumn> </MasterTableView> <ClientSettings AllowGroupExpandCollapse="True" AllowDragToGroup="True" AllowColumnsReorder="True" ColumnsReorderMethod="Reorder" ApplyStylesOnClient="True"> <Selecting AllowRowSelect="True" /> <Resizing AllowColumnResize="True" ResizeGridOnColumnResize="True" /> </ClientSettings> </radG:RadGrid> <tr> <td nowrap="nowrap"> <asp:Label ID="Label3" runat="server" meta:resourcekey="Label3Resource2" Text="Recipient(s)"></asp:Label></td> <td> <asp:Label ID="Label5" runat="server" CssClass="tips" meta:resourcekey="Label5Resource1" Text="use ; to separate multiple numbers"></asp:Label> <asp:TextBox ID="txtRecipient" runat="server" Visible="False"></asp:TextBox><asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtRecipient" ErrorMessage="RequiredFieldValidator" meta:resourcekey="ContactTextRequiredResource1" ToolTip="Mobile Number is required." ValidationGroup="SaveSMS">*</asp:RequiredFieldValidator> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtRecipient" ErrorMessage="Please enter numbers only" meta:resourcekey="contactValidatorResource1" ValidationExpression="[0-9]+" ValidationGroup="SaveSMS"></asp:RegularExpressionValidator> <asp:HiddenField ID="OutlogID" runat="server" /> </td> </tr> <tr> <td> <asp:Label ID="Label2" runat="server" meta:resourcekey="Label2Resource2" Text="SMS Text"></asp:Label></td> <td> <asp:TextBox ID="txtSMS" runat="server" Columns="50" Rows="5" TextMode="MultiLine"></asp:TextBox> <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="txtSMS" ErrorMessage="RequiredFieldValidator" meta:resourcekey="RequiredFieldValidator2Resource1" ValidationGroup="QuickSMS">*</asp:RequiredFieldValidator></td> </tr> - am getting downside Javascript Error.
Microsoft JScript runtime error: Unexpected ajax response was received from the server.
This may be caused by one of the following reasons:
- Server.Transfer.
- Custom http handler.
- Incorrect loading of an "Ajaxified" user control
Verify that you don't get a server-side exception or any other undesired behavior, by setting the EnableAJAX property to false.
Any one Please help me in this issue. am waiting for your reply.