Nov 25, 2012, 8:05 PM
[CLOSED] Show a modal dialog when exception is caught with message (MVC)
We are trying to find a solution to show a modal message when an exception occurs . We tried this but is not working. If we assign it to the directEventUrl in the button it works but does not work if it is not event. How can we achieve this as this is a critial part of our devlopment.
Index.cshtml
Index.cshtml
@{
ViewBag.Title = "Index";
}
@(Html.X().ResourceManager(ViewBag.ManagerConfig as MvcResourceManagerConfig))
@(Html.X().Panel()
.Items(items => items.Add(new TreePanel
{
ID = "exampleTree",
Header = false,
AutoScroll = true,
Lines = false,
UseArrows = true,
CollapseFirst = false,
RootVisible = false,
Store =
{
new TreeStore
{
Root =
{
new Node
{
NodeID = "Root",
Expanded = true
}
},
Proxy =
{
new AjaxProxy
{
API =
{
Read = Url.Action("GetTreeNodes"),
},
ActionMethods =
{
Read = HttpMethod.GET
},
}
}
}
},
}
))
)
SampleController.csusing System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ext.Net;
using Ext.Net.MVC;
namespace CompDesktop.Controllers
{
public class SampleController : Controller
{
//
// GET: /Sample/
public ActionResult Index()
{
return View();
}
public ActionResult GetTreeNodes()
{
var nc = new NodeCollection(false);
try
{
for (int i = 0; i < 10; i++)
{
Node n = new Node()
{
Text = "Node " + i,
IconCls = "",
Icon = Icon.Application
};
AddChildNode(n);
nc.Add(n);
}
//we are causing the exception for testing
int a = 0;
int b = 1;
int c = b / a;
return this.Content(c.ToString());
}
catch (Exception ex)
{
//this is not working
X.MessageBox.Alert("Error", ex.Message).Show();
return this.Direct();
}
}
private void AddChildNode(Node n)
{
for (int i = 0; i < 5; i++)
{
n.Children.Add(new Node() { Text = "Child " + i, Icon = Icon.ApplicationDouble, Leaf = true });
}
}
}
}
Last edited by Daniil; Dec 03, 2012 at 11:27 AM.
Reason: [CLOSED]