Rank: Newbie Groups: Member
Joined: 6/16/2007 Posts: 2
|
I'm try to handle errors on my site, my error page has the main menu as well. When I specify what roles can view menu items, the menu accesses the database to see if the user is in the role specified. If database connectivity goes down, for whatever reason, the menu throws the error. How can I trap this error? Since the menu is used on the errorpage, my exception handler generates a loop?
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,218
|
Hi, The easiest way is to enclose the data binding code in a try catch block. Try put the following code in your Page_Load:
Code: C#
try
{
Menu1.DataBind();
}
catch (Exception e)
{
//do whatever you'd like
}
I believe The menu automatically calls DataBind by default if you set its DataSourceID property. However if you call it manually in your code, the menu won't call it again automatically. Thanks
|