仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 572|回复: 9
打印 上一主题 下一主题

[学习教程] ASP网站制作之override deal with window closing in...

[复制链接]
简单生活 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-16 23:36:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
优点:简单易学、开发速度快、有很多年“历史”,能找到非常多别人做好的程序来用、配合activeX功能强大,很多php做不到的asp+activeX能做到,例如银行安全控件application|windowInthedatabaseapplicationdevelopment,theprogrammershouldoftendealwithonethingthatiswhentheusercloseawindow(calledForminDelphi)wheredatawasmaintained,theprogramshouldjudgewhetherthedatawaschangedwithoutsavingandwarntheuseraboutthiscase.Almostalltheprogrammercandealwiththiseasily,andthecodeisverysimpleasweknow.Thefollowingcode(writteninDelphi6)isthenormalmethodtodealwiththeproblem.ItisbaseononetablemaintenanceandthereareaDBGrid(namedDBGRid)whichshowsthedataofthetable,aDBEdit(namedDBEditName)whichcanbeusedtoeditthedataofthetableandsixButtons(respectivenamedBtnAdd,BtnModify,BtnDelete,BtnSave,BtnCancle,BtnClose).ThelastbuttonisusedtoclosetheFormandtheothersaredealingwiththedata.Ithinktheirnameshowtheirfunctionclearlyandnoexplanationisgivenhere.



unitUnit1;

interface

uses

Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,

Dialogs,ExtCtrls,StdCtrls,Buttons,Grids,DBGrids;

type

TForm1=class(TForm)

BtnModify:TBitBtn;

BtnCancel:TBitBtn;

BtnAdd:TBitBtn;

BtnDelete:TBitBtn;

BtnSave:TBitBtn;

BtnClose:TBitBtn;

DBGrid1:TDBGrid;

procedureFormCloseQuery(Sender:TObject;varCanClose:Boolean);

procedureBtnSaveClick(Sender:TObject);

private

{Privatedeclarations}

public

{Publicdeclarations}

protected

{Protecteddeclarations}

functionDataModifiedWithoutSaving():Boolean;virtual;abstract;

end;

varForm1:TForm1;

implementation

{$R*.dfm}

procedureTForm1.FormCloseQuery(Sender:TObject;

varCanClose:Boolean);

begin

ifDataModifiedWithoutSavingthen

begin

ifMessageDlg(Thedatahasbechangedwithoutsaving,wouldyoulikesavethedata?,mtWarning,[mbYes,mbNo],0)=mrNothen

begin

CanClose:=True;

endelsebegin

BtnSaveClick(Self);

CanClose:=True;

end;

end;

end;

procedureTForm1.BtnSaveClick(Sender:TObject);

begin

//

end;

end.



Theabovecodeisnotverygood(maybeyoucangiveamoreeffectone),butitreallycandealwiththeproblemwementionedatthebeginningofthepaper.Butletushaveathoughtnow;ifwegottwentyformsweshouldcopythecodeoftheFormCloseQueryfunctiontwentytimes.Doyouthinkitisaboringthing?Maybenot,buthowaboutthattheteamleaderdonotthinkthecodeyouhavewrittenisverygoodandhegivesyouanotherone?Thencopyagain?Ithinkitisneededtofindaneffectmethodtodealwiththisproblem.ThetoolIshowtheexamplehereisDelphi,ofcoursemanyothertoolsareusedinthesoftwarefieldsuchasVirsualC++,VirsualBasicandsoon.Butmostofthem(almostallofthem)arethetoolswhichsupportOOP(object-oriented
programming).ThethreemainpropertyofOOPareEncapsulation,InheritanceandDynamic.WecanusetheDynamicpropertytodealwiththeproblem.Todoso,weneedaformwhichhastheFormCloseQueryfunctiontobetheparentformofthosewherethedataismaintained.NowyoumayaskmeaquestionthatishowabouttheDataModifiedWithoutSavingfunction,thisfunctionhastobedifferentineveryform,andtheprogramshouldcalltheoneinthechildFormnottheoneintheparentForm.Yes,itisabsolutelyrightanditisjustwhattheDynamicdoes.WhenusingDelphi,thevirtualanddynamicmethodsshowthepropertyofDynamic.Virtualanddynamicmethods,unlikestaticmethods,canbeoverriddenindescendantclasses.Whenanoverriddenmethodiscalled,theactual(runtime)typeoftheclassorobjectusedinthemethodcallDnotthedeclaredtypeofthevariableDdetermineswhichimplementationtoactivate.[1]Dorememberthatthevirtualisneededhere,becausetheDelphiacceptthemethodtobestaticdefault.[1]



FunctionDataModifiedWithoutSaving():Boolean;virtual;abstract;



Anotherthingwehavetodoismoveitfromprivateparttotheprotectedpart,sincetheprivatepartcannotaccessoutoftheclass.AndIthinktheimplementationpartofthefunctionisuseless,soIdeletethispartanddeclarethef</p>大家可以自己去看一看.可以说看得想呕吐.以前有次下了个动网来看.里面连基本内置函数的保护措施(函数没防御性)都没有.难怪经常补这个补那个了.可能现在.NET版会好点吧
透明 该用户已被删除
沙发
发表于 2015-1-20 10:14:57 | 只看该作者
Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点)
莫相离 该用户已被删除
板凳
发表于 2015-1-24 11:18:08 | 只看该作者
另外因为asp需要使用组件,所以了解一点组件的知识(ADODB也是组件)
愤怒的大鸟 该用户已被删除
地板
发表于 2015-2-1 06:33:18 | 只看该作者
作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。
飘灵儿 该用户已被删除
5#
发表于 2015-2-7 01:27:04 | 只看该作者
ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。
第二个灵魂 该用户已被删除
6#
发表于 2015-2-19 08:20:50 | 只看该作者
还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。
蒙在股里 该用户已被删除
7#
发表于 2015-3-6 14:20:06 | 只看该作者
以上是语言本身的弱点,在功能方面ASP同样存在问题,第一是功能太弱,一些底层操作只能通过组件来完成,在这点上是远远比不上PHP/JSP,其次就是缺乏完善的纠错/调试功能,这点上ASP/PHP/JSP差不多。
简单生活 该用户已被删除
8#
 楼主| 发表于 2015-3-13 02:07:15 | 只看该作者
那么,ASP.Net有哪些改进呢?
冷月葬花魂 该用户已被删除
9#
发表于 2015-3-13 02:07:15 | 只看该作者
尽管MS自己讲C#内核中更多的象VC,但实际上我还是认为它和Java更象一些吧。首先它是面向对象的编程语言,而不是一种脚本,所以它具有面向对象编程语言的一切特性,比如封装性、继承性、多态性等等,这就解决了刚才谈到的ASP的那些弱点。
变相怪杰 该用户已被删除
10#
发表于 2015-3-20 09:25:58 | 只看该作者
Request:从字面上讲就是“请求”,因此这个是处理客户端提交的东东的,例如Resuest.Form,Request.QueryString,或者干脆Request("变量名")
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-9-23 02:20

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表