Jan 31, 2013, 3:04 PM
[CLOSED] Page load error handling
Hello,
The question is about handling page load errors and notifying user via Ext.Msg. The problem follows: When the DB is not accessible, page renders empty (as expected) but X.Msg is not shown. What is the correct way of handling those exceptions?
Thank you.
aspx:
aspx.cs:
The question is about handling page load errors and notifying user via Ext.Msg. The problem follows: When the DB is not accessible, page renders empty (as expected) but X.Msg is not shown. What is the correct way of handling those exceptions?
Thank you.
aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
<%@ Register assembly="Ext.Net" namespace="Ext.Net" tagprefix="ext" %>
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>"Combobox editor"</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server"/>
<ext:Store ID="GridPanel1Store" runat="server">
<Model>
<ext:Model ID="GridPanel1Model" runat="server" IDProperty="ID">
<Fields>
<ext:ModelField Name="ID" Type="Int"></ext:ModelField>
<ext:ModelField Name="Name" Type="String"></ext:ModelField>
</Fields>
</ext:Model>
</Model>
</ext:Store>
<div>
<ext:Viewport ID="Viewport1" runat="server" Layout="FitLayout">
<Items>
<ext:Panel ID="Panel1" runat="server" Layout="FitLayout" AutoScroll="true">
<Items>
<ext:GridPanel ID="GridPanel1" runat="server" StoreID="GridPanel1Store" MinHeight="200">
<ColumnModel runat="server" ID="ColumnModel1">
<Columns>
<ext:Column ID="Column1" runat="server" Text="ID" DataIndex="ID" Align="Left" Flex="1">
</ext:Column>
<ext:Column ID="Column2" runat="server" Text="Name" DataIndex="Name" Align="Left" Flex="1">
</ext:Column>
</Columns>
</ColumnModel>
</ext:GridPanel>
</Items>
</ext:Panel>
</Items>
</ext:Viewport>
</div>
</form>
</body>
</html>
aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
if (!X.IsAjaxRequest)
{
testEntities context = new testEntities();
try
{
var p = (from v in context.testTables select new { ID = v.ID, Name = v.Name });
GridPanel1Store.DataSource = p;
GridPanel1Store.DataBind();
}
catch (Exception exc)
{
Server.ClearError();
X.Msg.Show(new MessageBoxConfig
{
Title = "Error loading...",
Message = exc.Message,
Buttons = MessageBox.Button.OK,
Icon = MessageBox.Icon.ERROR
});
}
}
}
Last edited by Daniil; Feb 12, 2013 at 9:22 AM.
Reason: [CLOSED]