I have a problem with the RssReader when I put it in the DeclarativeCatalogPart and then try to add it (at runtime) to a WebPartZone I get the exception: rss url cannot be null.When I put the same RssReader usercontrol outside the catalog zone it works
fine.In both cases I set the RssUrl property to "~/GetArticlesRss.aspx".Please help me to solve this problem.
Seems weird to me. Check the code-behind of your Rss Reader user control (RssReader.ascx.cs). There should be a Page_Load method. Post your Page_Load method from this file and let us have a look at it.
I fixed this type error(Per to Pre) it is strange why didn't the compiler notify me for it?.
The compiler doesn't care what you call a method. The only reason we use Page_PreRender in this case is so that the runtime can use the AutoEventWireup to connect this so-named method to the PreRender event behind the scenes. If you wanted, you could instead
use a delegate to map the page's PreRender event to a method with any name you choose, like
protected void ThisIsMyPreRenderMethodBlahBlahBlah(object sender, Eventargs e). The compiler has no way of knowing what your intention is, so it doesn't check.
Your code seems okay to me. But, for some reason, it is throwing the ApplicationException you set up:
if (this.RssUrl.Length == 0)
throw new ApplicationException("Rss url cannot be null!");
This means it is seeing a Length of 0 in your RssUrl.
If it were me, I'd first try running the application straight from the download. That should definitely work.
Then, debug through the "working" code line by line, so you can see how it executes. It might help to set a Watch on RssUrl.Length.
Then, do exactly the same in your own code, and see how the program execution differs.
The big advantage we have in debugging this app is that we have a 100% certified working version we can always refer to.
Iam trying to perform your idea but the beer house solution has many rss webparts which make it taking very long time to go line by line.I have debug my solution for one rssReader control as a webpart and add it to a zone.First
RssUrl property set section is hit then the get section is hit and return lnkRss.NavigateUrl
as "" like if it was not set to the value "~/GetArticlesRss.aspx".Then the get section is hit again with the same result.Then the complier goes to the Page_Load where the DoBinding method exist then the exception is thrown.
When entering the catalog mode only the set section is hit(the get section is not hit).
Hope that you can help me to find what is happening because I really don't know what to do and what is happening.
Now the situation is more clear.I made another line by line debug.I found the the RssUrl property is set (lnkRss.NavigateUrl) correctly but after the compiler go to set the BaseWebPart properties the
lnkRss.NavigateUrl is forgotten.I don't know why?!
TheEagle
Member
71 Points
482 Posts
The Beer House Starter Kit Web Parts
Apr 17, 2008 06:21 PM|LINK
Hi,
I have a problem with the RssReader when I put it in the DeclarativeCatalogPart and then try to add it (at runtime) to a WebPartZone I get the exception: rss url cannot be null.When I put the same RssReader usercontrol outside the catalog zone it works fine.In both cases I set the RssUrl property to "~/GetArticlesRss.aspx".Please help me to solve this problem.
</div>Lee Dumond
Contributor
6404 Points
1173 Posts
Re: The Beer House Starter Kit Web Parts
Apr 17, 2008 07:49 PM|LINK
Seems weird to me. Check the code-behind of your Rss Reader user control (RssReader.ascx.cs). There should be a Page_Load method. Post your Page_Load method from this file and let us have a look at it.
Follow Me on Twitter
TheEagle
Member
71 Points
482 Posts
Re: The Beer House Starter Kit Web Parts
Apr 17, 2008 08:18 PM|LINK
Thank you for your respond...
The code you requested:
public RssReader() { this.Title = "RSS Reader"; } protected void Page_Load(object sender, EventArgs e) { DoBinding(); } protected void Page_PerRender(object sender, EventArgs e) { DoBinding(); } protected void DoBinding() { if (this.RssUrl.Length == 0) throw new ApplicationException("Rss url cannot be null!"); XmlDataDocument feed = new XmlDataDocument(); feed.Load(GetFullUrl(this.RssUrl)); XmlNodeList posts = feed.GetElementsByTagName("item"); DataTable tb = new DataTable("Feed"); tb.Columns.Add("Title",typeof(string)); tb.Columns.Add("Link", typeof(string)); tb.Columns.Add("Description", typeof(string)); tb.Columns.Add("PubDate", typeof(DateTime)); foreach (XmlNode node in posts) { DataRow row = tb.NewRow(); row["Title"] = node["title"].InnerText; row["Link"] = node["link"].InnerText; row["Description"] = node["description"].InnerText.Trim(); row["PubDate"] = DateTime.Parse(node["pubDate"].InnerText); tb.Rows.Add(row); } dlstRss.DataSource = tb; dlstRss.DataBind(); } private string GetFullUrl(string url) { if (url.StartsWith("/") || url.StartsWith("~/")) { url = (this.Page as BasePage).FullBaseUrl + url; url = url.Replace("~/", ""); } return url; } [Personalizable(PersonalizationScope.User),WebBrowsable,WebDisplayName("Rss Url"),WebDescription("The Url of the RSS feed")] public string RssUrl { get { return lnkRss.NavigateUrl; } set { lnkRss.NavigateUrl = value; } }Lee Dumond
Contributor
6404 Points
1173 Posts
Re: The Beer House Starter Kit Web Parts
Apr 17, 2008 08:55 PM|LINK
There's a typo in this code:
protected void Page_PerRender(object sender, EventArgs e) { DoBinding(); }Follow Me on Twitter
TheEagle
Member
71 Points
482 Posts
Re: The Beer House Starter Kit Web Parts
Apr 17, 2008 10:40 PM|LINK
I fixed this type error(Per to Pre) it is strange why didn't the compiler notify me for it?.
But the problem still as it is before(the exception is fired again when I add the RssReader WebPart to a WebPartZone at runtime).
Sometimes a series of errors appear about the RssReader and the PollBox user controls) but when I rebiuld the solution all of them disappear.
Lee Dumond
Contributor
6404 Points
1173 Posts
Re: The Beer House Starter Kit Web Parts
Apr 17, 2008 11:05 PM|LINK
The compiler doesn't care what you call a method. The only reason we use Page_PreRender in this case is so that the runtime can use the AutoEventWireup to connect this so-named method to the PreRender event behind the scenes. If you wanted, you could instead use a delegate to map the page's PreRender event to a method with any name you choose, like protected void ThisIsMyPreRenderMethodBlahBlahBlah(object sender, Eventargs e). The compiler has no way of knowing what your intention is, so it doesn't check.
Your code seems okay to me. But, for some reason, it is throwing the ApplicationException you set up:
if (this.RssUrl.Length == 0) throw new ApplicationException("Rss url cannot be null!");This means it is seeing a Length of 0 in your RssUrl.
If it were me, I'd first try running the application straight from the download. That should definitely work.
Then, debug through the "working" code line by line, so you can see how it executes. It might help to set a Watch on RssUrl.Length.
Then, do exactly the same in your own code, and see how the program execution differs.
The big advantage we have in debugging this app is that we have a 100% certified working version we can always refer to.
Follow Me on Twitter
TheEagle
Member
71 Points
482 Posts
Re: The Beer House Starter Kit Web Parts
Apr 20, 2008 08:11 AM|LINK
Iam trying to perform your idea but the beer house solution has many rss webparts which make it taking very long time to go line by line.I have debug my solution for one rssReader control as a webpart and add it to a zone.First RssUrl property set section is hit then the get section is hit and return lnkRss.NavigateUrl as "" like if it was not set to the value "~/GetArticlesRss.aspx".Then the get section is hit again with the same result.Then the complier goes to the Page_Load where the DoBinding method exist then the exception is thrown.
When entering the catalog mode only the set section is hit(the get section is not hit).
Hope that you can help me to find what is happening because I really don't know what to do and what is happening.
TheEagle
Member
71 Points
482 Posts
Re: The Beer House Starter Kit Web Parts
Apr 21, 2008 05:54 PM|LINK