Consuming rss feed preventing error on server down

B

Bo

Hope somebody can help me.

I show some remote rss feeds on my page with this code. But if the remote
server is down how do prevent my page from getting an error? In short how do
I add some code so it gives up trying to load the remote rss feed if it's
not online?

In the code behind.....

Protected Sub Genres_SelectedIndexChanged(ByVal sender As Object, ByVal e As
EventArgs)
UpdateGenre()
End Sub

Private Sub UpdateGenre()
GenreSource.DataFile = Genres.SelectedValue
GenreNews.DataBind()
System.Threading.Thread.Sleep(2000)
End Sub
Protected Sub UpdateNews(ByVal sender As Object, ByVal e As EventArgs)
UpdateGenre()
'GenrePanel.Update();
End Sub


on the aspx page....

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/scripts/DummyScript.js" />
</Scripts>
</asp:ScriptManagerProxy><asp:UpdatePanel ID="GenrePanel" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:DropDownList ID="Genres" runat="server"
AutoPostBack="True" OnSelectedIndexChanged="Genres_SelectedIndexChanged"
CssClass="mytext">
<asp:ListItem Text="Link"
Value="http://www.whatever.com/rss" Selected="true" />
</asp:DropDownList>
<asp:UpdateProgress ID="UpdatingNews" runat="server"
AssociatedUpdatePanelID="GenrePanel" >
<ProgressTemplate>
<img src="pics/indicator.gif" alt="" />&nbsp;Getting
....
</ProgressTemplate>
</asp:UpdateProgress>
<br /><br />
<asp:Repeater ID="GenreNews" runat="server"
DataSourceID="GenreSource" >
<ItemTemplate>
<div class="mytext">
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%#XPath("link") %>' Text='<%#XPath("title") %>'
Target="_blank" Font-Bold="true" />
</div>
</ItemTemplate>
</asp:Repeater>
</ContentTemplate>
</asp:UpdatePanel>
<asp:XmlDataSource runat="server"
DataFile="http://www.whatever.com/rss" ID="GenreSource"
XPath="/rss/channel/item [position()<=5]">
</asp:XmlDataSource>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top