asp code to Rotate page based on the day

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2009
Posts: 2
Reputation: gautamrekolan is an unknown quantity at this point 
Solved Threads: 0
gautamrekolan gautamrekolan is offline Offline
Newbie Poster

asp code to Rotate page based on the day

 
0
  #1
Sep 19th, 2009
HI,

I am new to asp.net.

I have 365 pages and i want to display each of those on 365 days

say I have a page to be displayed on sept 19..

on clicking the Enter site it should validate which day and should navigate to that particular page.

looking forward for all your support

Gautam
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 136
Reputation: cVz is an unknown quantity at this point 
Solved Threads: 7
cVz's Avatar
cVz cVz is offline Offline
Junior Poster

Re: asp code to Rotate page based on the day

 
1
  #2
Sep 20th, 2009
HI my friend...

assuming that you have 365 pages already made, you could do the following

- THIS IS A QUICK FIX

What you need is a table in your database with 3 columns

1. PrimaryKey INT, NOT NULL
2. Date DATETIME
3. NavigateURL VARCHAR(MAX)

In your database you will have a page per day linked to the date.

You can use this script

  1. CREATE PROCEDURE TEMP_Procedure
  2. AS
  3. BEGIN
  4. DECLARE @START INT
  5. DECLARE @END INT
  6.  
  7. SET @START = 0
  8. SET @END = 356
  9.  
  10. Secondly you need TO ADD the dates
  11. DECLARE @StartDate DATETIME
  12. SET @StartDate = (The DATE you want TO START ON)
  13.  
  14. WHILE @START <= @END
  15. BEGIN
  16. INSERT INTO dbo.YourTableName
  17. (
  18. PrimaryKey
  19. , DATE
  20. )
  21. VALUES
  22. (
  23. @START
  24. , @StartDate
  25. )
  26. @START = @START + 1
  27. @StartDate = DATEADD(@StartDate , DAY, 1) -- Play with the sequence as i am a bit unsure of the sequence
  28. END

This will give you the Identities per page
as well as the dates
...

now all you need to do is specify the page.

--------------------------------------------------------

No in your code you can fill a dataset with the URL

Your query will look like this

string.Format("SELECT NavigateURL FROM Table WHERE Date = '{0}'", DATETIME.NOW.DATE);

and then you will redirect

Response.Redirect(DataSetName.Tables[0].Rows[0][0/*this is the column*/].ToString());

There you go mate , have a good one...
Delphi & C# programmer deluxe...
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 3,200
Reputation: sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of sknake has much to be proud of 
Solved Threads: 571
Sponsor
sknake's Avatar
sknake sknake is offline Offline
.NET Enthusiast

Re: asp code to Rotate page based on the day

 
0
  #3
Sep 20th, 2009
After you login just call a redirect based on the day of year:
  1. string url = string.Format("/page_{0:F0}.aspx", DateTime.Today.DayOfYear);
  2. Response.Redirect(url);

You could also use the method cVz posted if you are using a database.
Scott Knake
Custom Software Development
Apex Software, Inc.
Reply With Quote Quick reply to this message  
Reply

Tags
asp.net, rotatepage, validatedate

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC