This question is locked. New answers and comments are not allowed.
Hi,
I'm trying to implement a custom client side error function for my grid so that I can effectively handle the time-outs from Forms Authentication. I have a custom authorisation filter in my MVC app that handles unauthenticated AJAX calls and returns a 403 Forbidden status.
My view is as follows:
The onError function is declared as explained in the help files but is not firing when the error is returned. The default handling is firing and displaying the error in an alert box.
Have I declared the client event correctly? Can you see why my custom function is not being called?
Thanks,
Nick
I'm trying to implement a custom client side error function for my grid so that I can effectively handle the time-outs from Forms Authentication. I have a custom authorisation filter in my MVC app that handles unauthenticated AJAX calls and returns a 403 Forbidden status.
My view is as follows:
<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/SingleColumn.Master" Inherits="System.Web.Mvc.ViewPage" %> |
<asp:Content ID="cTitle" ContentPlaceHolderID="TitleContent" runat="server"> |
Index |
</asp:Content> |
<asp:Content ID="cHeader" ContentPlaceHolderID="HeaderContent" runat="server"> |
</asp:Content> |
<asp:Content ID="cMain" ContentPlaceHolderID="MainContent" runat="server"> |
<h1>Index</h1> |
<% |
Dim grid As Telerik.Web.Mvc.UI.Grid(Of PortalAudit) = Html.Telerik.Grid(Of PortalAudit) _ |
.Name("AuditGrid") _ |
.Ajax(Function(g) g.Action("AuditListing", "Audit")) _ |
.Pageable(Function(p) p.Total(CInt(ViewData("Total")))) _ |
.Sortable() _ |
.Filterable() _ |
.EnableCustomBinding(True) _ |
.ClientEvents(Function(events) events.OnError("onGridError")) |
grid.Paging.PageSize = 20 |
Dim colUserName As New Telerik.Web.Mvc.UI.GridColumn(Of PortalAudit)(Function(a) a.UserName) |
Dim colAction As New Telerik.Web.Mvc.UI.GridColumn(Of PortalAudit)(Function(a) a.Action) |
Dim colController As New Telerik.Web.Mvc.UI.GridColumn(Of PortalAudit)(Function(a) a.Controller) |
colController.Title = "Area" |
Dim colAffectedEntity As New Telerik.Web.Mvc.UI.GridColumn(Of PortalAudit)(Function(a) a.AffectedEntity) |
Dim colStatus As New Telerik.Web.Mvc.UI.GridColumn(Of PortalAudit)(Function(a) a.Status) |
Dim colDescription As New Telerik.Web.Mvc.UI.GridColumn(Of PortalAudit)(Function(a) a.Description) |
Dim colTimeStamp As New Telerik.Web.Mvc.UI.GridColumn(Of PortalAudit)(Function(a) a.DateStamp) |
colTimeStamp.Title = "DateStamp" |
colTimeStamp.Format = "{0:dd/MM/yyyy HH:mm}" |
grid.Columns.Add(colUserName) |
grid.Columns.Add(colController) |
grid.Columns.Add(colAction) |
grid.Columns.Add(colAffectedEntity) |
grid.Columns.Add(colStatus) |
grid.Columns.Add(colDescription) |
grid.Columns.Add(colTimeStamp) |
grid.Render() |
%> |
</asp:Content> |
<asp:Content ID="cScript" ContentPlaceHolderID="ScriptContent" runat="server"> |
<script type="text/javascript"> |
function onGridError(e) { |
alert("You have invoked the custom error function!"); |
e.preventDefault(); |
var xhr = e.XMLHttpRequest; |
alert(xhr.status); |
if (xhr.status == 403) { |
alert("redirecting to login page"); |
window.location = window.location; |
} |
else { |
alert(e.textStatus); |
} |
} |
</script> |
</asp:Content> |
The onError function is declared as explained in the help files but is not firing when the error is returned. The default handling is firing and displaying the error in an alert box.
Have I declared the client event correctly? Can you see why my custom function is not being called?
Thanks,
Nick