Search code examples
asp.netexceptionmarkup

catching exceptions in asp.net markup


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?


Solution

  • 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.