逍遥一派 发表于 2015-2-3 23:40:22

ASP网站制作之Dynamic Date Drop-down Boxes

减少客户内IT专业人才缺乏带来的影响。ASP的客户员工利用浏览器进入相关的应用软件,简单易用,无需专业技术支持。   By Kevin Perkins

Article

Article:

One thing I've learned over the last few years is to use techniques in my applications that make it easy to debug and maintain, especially if you leave the project and have to come back to it at a later time.

Besides error handling and commenting, I try to automate as much as possible to make maintenance a cake-walk. One area that can be tremendously automated is implementing date structures in your application.

For instance... if you're building an ecommerce application, you'll eventually have to deal with credit card expiry. The predominant technique for handling expiration dates is to use two drop-down boxes representing the month and the year. Having said that, it's very easy to hard-code those dates in each drop-down box.... 1-12 for month, but what to what for the year? Do you use the current year (2000) and the following two (2001,2002) ?

What happens when we're in year 2001? You'll have an older entry for the previous year (2000), and you'll be one short for the future (2002,?). This is bad practice because your application should be smart enough to remove previous years that are invalid to present-day transactions, as well as account for new credit cards that might have an expiration date farther in the future.

To work with drop-down dates dynamically, I determine the current month, current year, and how far into the future I want to account for expiration. My rule is 5 years, but each application is different:

<%@LANGUAGE=VBSCRIPT%>

<%
' ----------------------------------------------------------------------------------
' You could use similar looping techniques with JavaScript
' ----------------------------------------------------------------------------------
%>

<html>
<head></head>
<body>

<form>

<%
' ----------------------------------------------------------------------------------
' Build the MONTH drop-down box
' ----------------------------------------------------------------------------------

iMonth = Month(Now())
' This produces the current month's integer (ex. 7)
%>

<select name="drpMonth">
<% For i = 1 to 12 %>
<option <%
' This will select the current month in the list
If CInt(iMonth = i) Then
Response.Write "selected "
End if
%>value="<%= i %>"><%= i %></option>
<% Next %>
</select>


<!-- Drop-down separator -->
/
<!-- End separator -->


<%
' ----------------------------------------------------------------------------------
' Build the YEAR drop-down box
' ----------------------------------------------------------------------------------

iYear = Year(Now())
' This produces the current year's integer (ex. 2000)
%>


<select name="drpYear">
<% For i = iYear to ( CInt(iYear + 5) ) %>
<option <%
' This will select the current year in the list
If CInt(iYear = i) Then
Response.Write "selected "
End if
%>value="<%= i %>"><%= i %></option>
<% Next %>
</select>


</form>

</body>
</html>



Of course, if you have more complex date interactions, you can manipulate the If/Then statement inside of the loop to select the appropriate value. And, if you're working with dates in the past, you can reindex the starting value of (i) by subtracting how many years you want to go back...

Example:
"For i = iYear to ..." tells the application to do something "From 2000 to ..."
"For i = CInt(iYear - 2) to ..." tells the application to do something "From 1998 to ... "

-END-

</p>Access是一种桌面数据库,只适合数据量少的应用,在处理少量数据和单机访问的数据库时是很好的,效率也很高。但是它的同时访问客户端不能多于4个。access数据库有一定的极限,如果数据达到100M左右,很容易造成服务器iis假死,或者消耗掉服务器的内存导致服务器崩溃。

不帅 发表于 2015-2-4 05:30:30

我想问如何掌握学习节奏(先学什么再学什么)最好详细点?

飘灵儿 发表于 2015-2-6 04:08:48

我们必须明确一个大方向,不要只是停留在因为学而去学,我们应有方向应有目标.

第二个灵魂 发表于 2015-2-10 03:11:25

尽管MS自己讲C#内核中更多的象VC,但实际上我还是认为它和Java更象一些吧。首先它是面向对象的编程语言,而不是一种脚本,所以它具有面向对象编程语言的一切特性,比如封装性、继承性、多态性等等,这就解决了刚才谈到的ASP的那些弱点。

只想知道 发表于 2015-2-16 07:54:30

运用经典的例子。并且自己可以用他来实现一些简单的系统。如果可以对他进行进一步的修改,找出你觉得可以提高性能的地方,加上自己的设计,那就更上一个层次了,也就会真正地感到有所收获。

飘飘悠悠 发表于 2015-2-20 16:03:44

学习ASP其实应该上升到如何学习程序设计这种境界,其实学习程序设计又是接受一种编程思想。比如ASP如何学习,你也许在以前的学习中碰到过。以下我仔细给你说几点:

因胸联盟 发表于 2015-2-23 11:12:35

学习是为了用的,是为了让你的程序产生价值,把握住这个原则会比较轻松点。除此之外,课外时间一定要多参加一些社会实践活动,来锻炼自己的能力。

分手快乐 发表于 2015-3-1 09:28:22

如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助:

变相怪杰 发表于 2015-3-3 21:39:15

你可以通过继承已有的对象最大限度保护你以前的投资。并且C#和C++、Java一样提供了完善的调试/纠错体系。

乐观 发表于 2015-3-8 15:30:10

另外因为asp需要使用组件,所以了解一点组件的知识(ADODB也是组件)

莫相离 发表于 2015-3-16 03:05:55

那么,ASP.Net有哪些改进呢?

愤怒的大鸟 发表于 2015-3-20 00:47:19

没有坚实的理论做基础,那么我们连踏入社会第一步的资本都没有,特别对于计算机专业的学生学好专业知识是置关重要的。在这里我侧重讲一下如何学习ASP,从平时的学习过程中。

小妖女 发表于 2015-3-22 19:08:22

虽然ASP也有很多网络教程。但是这些都不系统。都是半路出家,只是从一个例子告诉你怎么用。不会深入讨论,更不会将没有出现在例子里的方法都一一列举出来。

灵魂腐蚀 发表于 2015-3-31 23:03:22

以上是语言本身的弱点,在功能方面ASP同样存在问题,第一是功能太弱,一些底层操作只能通过组件来完成,在这点上是远远比不上PHP/JSP,其次就是缺乏完善的纠错/调试功能,这点上ASP/PHP/JSP差不多。

精灵巫婆 发表于 2015-4-1 02:20:02

不是很难但是英文要有一点基础网上的教程很少有系统的详细的去买书吧,另不用专门学习vb关于vbscript脚本在asp教材都有介绍

透明 发表于 2015-4-1 21:12:08

我可以结合自己的经验大致给你说一说,希望对你有所帮助,少走些弯路。

再现理想 发表于 2015-4-10 23:27:59

ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题:

逍遥一派 发表于 2015-4-21 04:59:14

哪些内置对象是可以跳过的,或者哪些属性和方法是用不到的?

小魔女 发表于 2015-5-1 08:10:36

学习ASP其实应该上升到如何学习程序设计这种境界,其实学习程序设计又是接受一种编程思想。比如ASP如何学习,你也许在以前的学习中碰到过。以下我仔细给你说几点:

深爱那片海 发表于 2015-5-11 02:37:07

ASP.Net和ASP的最大区别在于编程思维的转换,而不仅仅在于功能的增强。ASP使用VBS/JS这样的脚本语言混合html来编程,而那些脚本语言属于弱类型、面向结构的编程语言,而非面向对象,这就明显产生以下几个问题:
页: [1] 2
查看完整版本: ASP网站制作之Dynamic Date Drop-down Boxes