views:

44

answers:

2

How does one go about catching exceptions from using controls in markup?

For example, I have the following code

<asp:XmlDataSource ID="XmlDataSource1" 
                   runat="server" 
                   DataFile="http://feeds.feedburner.com/"
                   XPath="rss/channel/item [position()<=10]"></asp:XmlDataSource>

If feedburner is down for whatever reason, where does the exception get thrown too and how do I catch this?

+2  A: 

I would probably resort to setting the properties in code behind and handling the data binding manually within a try/catch block. This would allow you to eat the exception and put up some sort of error message.

tvanfosson
Never considered that :-)
Sir Psycho
+1  A: 

You could always let it fall through to Application_Error in Global.asax.cs, if you have any kind of global error handling in place.

darasd