You are not alone - the stored procedures NextAnnouncement and NextPrevAnnouncement both also have no logic in them to suppress items with dates in the future. As well, the logic in News_View where it decides if the next and previous links should be hot
is not quite right, it doesn't know if the link is hot until after you click it (click next until you get to the end, it will allow you one more click which does nothing before it makes the link disabled). This should be rewritten somehow.
I'm not motivated to work on this particular issue myself, but what I would probably do is something like make a single procedure which
-builds a temp list of viewable items where itemdate <= getdate()
-selects from temp the previous item id into a variable (null if we are at the first one) @prev
-selects from temp the next item id into a variable (null if we are at the last one) @next
-selects the item we want into a variable @item
then select bla, bla, bla,@prev, @next from announcements where id = @item
now we have all the info to make the page in one go
so in sqldatasource1_selected() we can set whether the next and previous links go anywhere.
If you don't want to do this, and your site depends heavily on being able to create news items that are hidden until the due date, then I would just remove the next/prev links from news_view, I don't think they are that useful, even if they are cool. They
also have this unpleasant side effect in that the URL does not change, so if you go to article 6 and then use the next link to move to article 7, and you bookmark the page, the bookmark will point to ... article 6. Kinda weird. Not so big an issue in the list
pages, but odd in a content page.
Lex et al, isn't this problem solved by modifying the stored procedures to add an itemdate < GETDATE() condition?
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
go
ALTER PROCEDURE [whatever].[NextPrevAnnouncement]
(
@id int,
@previd int output,
@nextid int output
)
AS
/* SET NOCOUNT ON */
DECLARE @curr datetime
SELECT @curr = itemdate
FROM Announcements
WHERE (id = @id)
SELECT @previd= id
FROM Announcements
WHERE (itemdate < @curr OR
(itemdate = @curr) AND (id < @id))
ORDER BY itemdate ASC, id ASC
SELECT @nextid= id
FROM Announcements
WHERE (itemdate < GETDATE() AND
(itemdate > @curr OR
((itemdate = @curr) AND (id > @id))))
ORDER BY itemdate DESC, id DESC
You would have to modify NextAnnouncement and NextPrevAnnouncement this way. There was some related logic in the News_View.aspx that was broken. It had to do with next/previous clicks, and deciding which items were valid and
which not. See here for a description of the problem and a fix.
I want to let my concerns to be known here in this thread. First I should say that I am new to asp.net I have done some codeing in VB6 but that was only to get my degree in business administration and networking. I was happy as a pig in shit when I came across
this paticular subject. I read alotif not all of the submitted bugs and their fixes and let me tell you it was not easy. I am going to say that the easiest to follow was the very first fix and that is only because I could find the line and the code in a instance.Some
one had mentioned that it would be nice if people posting could give the line number and the name of the file. This would aid in why we are here in the first place, and that is to find fixes for what we can not fix on our own. I see that this thread has had
a short life it is a nowonder and perhaps it can be brought back to life with a little simplicity and straightforwardness.
First off, let me say that I wish I would have found this on Monday instead of Friday night! I am currently working through this post to correct all the bugs / issues and many thanks to everyone who posted. Now for my comment. I, too, added the required
field validator to fix the error thrown when adding events but neglecting to add a description. The problem started when I fixed another error with the same page where one clicks "Cancel" without entering anything (Bug #5 by BugSlayer on page 3 of this thread);
the cancel button doesn't work because no description is entered for the cancelled addition.
1. Make the change outlined in Bug #5 AND add a required validator as described above.
2. Recreate the exact steps in Bug #5.
3. Instead of throwing an error (as happened before BugSlayer's fix), the cancel button does nothing beause the server validates the control, determines it is null (which is invalid), and prevents the cancellation. End result is that Cancel does nothing and
the user must navigate using another means.
My fix for this will be to pass a parameter from each of the two pages that permit adding events; the calendar view and the list view (I know there's a third but it shouldn't be there in my opinion). Each page will (once I figure out how - yes I'm a noob)
pass the same parameter with a different value to permit Cancel to return me to the page where I started. I'm not sure why I'm returned to the Events_View page instead of from where I started.
lexy
Participant
1668 Points
441 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 12, 2006 05:44 PM|LINK
Hi,
What problem are you guys adressing here?
I thought my problems were solved with:
SELECT top 5 [id], [itemdate], [title], [description], [photo] FROM [Announcements]
WHERE itemdate <= GETDATE() ORDER BY itemdate DESC
Lex
MrLunch
Member
727 Points
144 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 12, 2006 06:47 PM|LINK
Forums Starter Kit
lexy
Participant
1668 Points
441 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 12, 2006 09:24 PM|LINK
Ah,
..... now I understand.
Indeed NewsList does not show any news before the projected date.
However in NewsView when I click on Next Article I still get to see the article before it's due.
Am I alone in this?
regards,
Lex
MrLunch
Member
727 Points
144 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 12, 2006 10:14 PM|LINK
You are not alone - the stored procedures NextAnnouncement and NextPrevAnnouncement both also have no logic in them to suppress items with dates in the future. As well, the logic in News_View where it decides if the next and previous links should be hot is not quite right, it doesn't know if the link is hot until after you click it (click next until you get to the end, it will allow you one more click which does nothing before it makes the link disabled). This should be rewritten somehow.
I'm not motivated to work on this particular issue myself, but what I would probably do is something like make a single procedure which
-builds a temp list of viewable items where itemdate <= getdate()
-selects from temp the previous item id into a variable (null if we are at the first one) @prev
-selects from temp the next item id into a variable (null if we are at the last one) @next
-selects the item we want into a variable @item
then select bla, bla, bla,@prev, @next from announcements where id = @item
now we have all the info to make the page in one go
so in sqldatasource1_selected() we can set whether the next and previous links go anywhere.
If you don't want to do this, and your site depends heavily on being able to create news items that are hidden until the due date, then I would just remove the next/prev links from news_view, I don't think they are that useful, even if they are cool. They also have this unpleasant side effect in that the URL does not change, so if you go to article 6 and then use the next link to move to article 7, and you bookmark the page, the bookmark will point to ... article 6. Kinda weird. Not so big an issue in the list pages, but odd in a content page.
Forums Starter Kit
lexy
Participant
1668 Points
441 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 13, 2006 06:35 AM|LINK
Hi mark,
Removing or hiding the linkbuttons is the way to go for me at this point. Cleans the page up quite nicely at the same go.
Perhaps in the future when I know a little bit more about this stuff I'll address it.
I wish everybody that is not motivated to tackle a problem would be so willing to desribe that same problem.
Many thanks,
Lex
cheeso
Member
342 Points
75 Posts
Re: News items show before their time
Jul 13, 2006 01:36 PM|LINK
Lex et al, isn't this problem solved by modifying the stored procedures to add an itemdate < GETDATE() condition?
set ANSI_NULLS ON set QUOTED_IDENTIFIER ON go ALTER PROCEDURE [whatever].[NextPrevAnnouncement] ( @id int, @previd int output, @nextid int output ) AS /* SET NOCOUNT ON */ DECLARE @curr datetime SELECT @curr = itemdate FROM Announcements WHERE (id = @id) SELECT @previd= id FROM Announcements WHERE (itemdate < @curr OR (itemdate = @curr) AND (id < @id)) ORDER BY itemdate ASC, id ASC SELECT @nextid= id FROM Announcements WHERE (itemdate < GETDATE() AND (itemdate > @curr OR ((itemdate = @curr) AND (id > @id)))) ORDER BY itemdate DESC, id DESCYou would have to modify NextAnnouncement and NextPrevAnnouncement this way. There was some related logic in the News_View.aspx that was broken. It had to do with next/previous clicks, and deciding which items were valid and which not. See here for a description of the problem and a fix.
MrLunch
Member
727 Points
144 Posts
Re: News items show before their time
Jul 13, 2006 06:33 PM|LINK
Forums Starter Kit
Omark78
Member
10 Points
2 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 29, 2006 05:34 PM|LINK
I just added the required field validator on top of the description textbox and it worked fine with me. Sample code below
<asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Event description cannot be empty" ControlToValidate ="descriptionTextBox"></asp:RequiredFieldValidator>
<asp:TextBox Text='<%# Bind("description") %>' runat="server" ID="descriptionTextBox" Rows="10" TextMode="MultiLine" Width="500px" Height="166px"></asp:TextBox>DKB
Member
201 Points
263 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Jul 31, 2006 06:21 PM|LINK
cougar6
Member
20 Points
4 Posts
Re: Identified bugs and fixes for the ClubSite Starter kit
Aug 05, 2006 07:19 AM|LINK
1. Make the change outlined in Bug #5 AND add a required validator as described above.
2. Recreate the exact steps in Bug #5.
3. Instead of throwing an error (as happened before BugSlayer's fix), the cancel button does nothing beause the server validates the control, determines it is null (which is invalid), and prevents the cancellation. End result is that Cancel does nothing and the user must navigate using another means.
My fix for this will be to pass a parameter from each of the two pages that permit adding events; the calendar view and the list view (I know there's a third but it shouldn't be there in my opinion). Each page will (once I figure out how - yes I'm a noob) pass the same parameter with a different value to permit Cancel to return me to the page where I started. I'm not sure why I'm returned to the Events_View page instead of from where I started.