473,388 Members | 1,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Autochange a date in .aspx files

Daily I have to manually change the date on a index.aspx
page,then upload it on FTP,what would be the C# code which changes the date automatically on a daily basis,I tried this script:
Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2. <!--
  3. var days=new Array(8);
  4. days[1] = "Sun";
  5. days[2] = "Mon";
  6. days[3] = "Tue";
  7. days[4] = "Wed";
  8. days[5] = "Thu";
  9. days[6] = "Fri";
  10. days[7] = "Sat";
  11. var months=new Array(13);
  12. months[1] = "Jan";
  13. months[2] = "Feb";
  14. months[3] = "Mar";
  15. months[4] = "Apr";
  16. months[5] = "May";
  17. months[6] = "Jun";
  18. months[7] = "Jul";
  19. months[8] = "Aug";
  20. months[9] = "Sep";
  21. months[10] = "Oct";
  22. months[11] = "Nov";
  23. months[12] = "Dec";
  24. var dateObj=new Date()
  25. var wday=days[dateObj.getDay() + 1]
  26. var lmonth=months[dateObj.getMonth() + 1]
  27. var date=dateObj.getDate()
  28. var year=dateObj.getYear()
  29. if (year >= 100 && year <= 1999)
  30. {year=year + 1900}
  31. else
  32. {year=year}
  33. document.write(date+ " " + lmonth + " " + year)
  34. </script>
The problem is that it accepts the date of the users machine which is incorrect.
Aug 9 '12 #1
4 2146
ariful alam
185 100+
If you want to view the server machine date, you have to code it using the language you used in your ASP.net .aspx page (C#.net, VB.net. etc.). JavaScript is able to track the client side information like this. Just a server side scripting language can track this kind of information from the server machine.

Just convert your JavaScript techniques to ASP.net language code.

Hope it's work for you. :)
Aug 9 '12 #2
Frinavale
9,735 Expert Mod 8TB
You can get the current date in your server-side code using the DateTime.Now static property.

In JavaScript, if you want the date use the Date Object.

-Frinny
Aug 9 '12 #3
I have tried your first link, even in that when I change my machines date the changed date is reflected.I have used C# while testing the required output.
Aug 17 '12 #4
Frinavale
9,735 Expert Mod 8TB
If you want the server's date to be the one that appears on the website, use the .NET DateTime to display it.

The server code does not care about the client's code...so that leads me to believe that maybe your server's operating system is set to the wrong date/time?

It may help if you posted your current code so that we can see if it's something your code is doing or something else.

-Frinny
Aug 17 '12 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Chuck Bowling | last post by:
I'm doing something wrong... not quite sure what... I got a basic web forms page built and running inside the IDE per ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/vbcon/html/vbwlkWalkthroughCr...
2
by: Glen | last post by:
As I understand it, when the first page of an application is accessed, all ASPX/ASCX/etc. files in the same folder are compiled using the JIT compiler. Is there a way to turn this feature off? ...
5
by: M Luper | last post by:
I have visualStudio.NET on my laptop. The OS on the laptop is XP Proffesional. When I installed visualStudio.NET on my laptop I thought that all of the dotnet framework was installed, but when I...
7
by: Bennett Haselton | last post by:
If you create a ASP.Net Web application in Visual Studio .Net, you apparently have to specify the target as a directory on a web server, e.g. www.hostname.com/dirname, with "dirname" being the name...
1
by: J | last post by:
I have some .aspx files that need to run on our web server. Looking through the newsgroups I believe these things are true: 1. .aspx files are "asp dot net" files 2. In order for these to run...
0
by: Jonaed | last post by:
Hello, I am having a problem with caching, or at least I think it is with caching. I have a simple <%= "text " + DateTime.Now.ToString() %> in one of my aspx files (that is included thru the...
4
by: Ed | last post by:
Recently I got a new laptop and placed my Visual Studio 2003 project on it. But when I place my aspx files in design mode the aspx files don't design right. I used grid layout (not flow) and...
18
by: Boris Yeltsin | last post by:
I'm using a Web Deployment Project under Visual Studio 2005. What I would love to be able to deploy to a fresh server is just the \bin folder and the web.config (and perhaps a couple of other...
3
by: =?Utf-8?B?SmVmZnJleQ==?= | last post by:
Just got the book, ASP.NET by Greg Buczek (Osborne). The first part of book listed many aspx codes, not created by VS 2003 or VS 2005. How can these aspx files be coded? NotePad or VB 6? The...
1
by: djnokturnal | last post by:
Hey guys/gals, I have successfully implemented forms authentication on my site: <authentication mode="Forms"> <forms loginUrl="/Members/Login.aspx" timeout="20"...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.