943,867 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 1267
  • ASP.NET RSS
Sep 19th, 2009
0

asp code to Rotate page based on the day

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
gautamrekolan is offline Offline
2 posts
since Sep 2009
Sep 20th, 2009
1

Re: asp code to Rotate page based on the day

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

TSQL Syntax (Toggle Plain Text)
  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...
cVz
Reputation Points: 29
Solved Threads: 7
Junior Poster
cVz is offline Offline
139 posts
since Mar 2008
Sep 20th, 2009
0

Re: asp code to Rotate page based on the day

After you login just call a redirect based on the day of year:
ASP.NET Syntax (Toggle Plain Text)
  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.
Featured Poster
Reputation Points: 1749
Solved Threads: 735
Senior Poster
sknake is offline Offline
3,948 posts
since Feb 2009

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: F5 debug mode for ASP.NET Application “Not in Debugger Group” Warning
Next Thread in ASP.NET Forum Timeline: ASP.NET MVC redirect problem





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC