仓酷云
标题:
ASP网站制作之override deal with window closing in...
[打印本页]
作者:
简单生活
时间:
2015-1-16 23:36
标题:
ASP网站制作之override deal with window closing in...
优点:简单易学、开发速度快、有很多年“历史”,能找到非常多别人做好的程序来用、配合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
Application:这个存储服务端的数据,如果不清除,会直到web应用程序结束才清除(例如重启站点)
作者:
莫相离
时间:
2015-1-24 11:18
另外因为asp需要使用组件,所以了解一点组件的知识(ADODB也是组件)
作者:
愤怒的大鸟
时间:
2015-2-1 06:33
作为IE上广为流传的动态网页开发技术,ASP以它简单易学博得了广大WEB程序爱好这的青睐,而且它对运行环境和开发品台的不挑剔,以及有大量有效的参考手册,极大的推广了它的发展。
作者:
飘灵儿
时间:
2015-2-7 01:27
ASP主要是用好六个对象,其实最主要的是用好其中两个:response和request,就可以随心所欲地控制网页变换和响应用户动作了。
作者:
第二个灵魂
时间:
2015-2-19 08:20
还有如何才能在最短的时间内学完?我每天可以有效学习2小时,双休日4小时。
作者:
蒙在股里
时间:
2015-3-6 14:20
以上是语言本身的弱点,在功能方面ASP同样存在问题,第一是功能太弱,一些底层操作只能通过组件来完成,在这点上是远远比不上PHP/JSP,其次就是缺乏完善的纠错/调试功能,这点上ASP/PHP/JSP差不多。
作者:
简单生活
时间:
2015-3-13 02:07
那么,ASP.Net有哪些改进呢?
作者:
冷月葬花魂
时间:
2015-3-13 02:07
尽管MS自己讲C#内核中更多的象VC,但实际上我还是认为它和Java更象一些吧。首先它是面向对象的编程语言,而不是一种脚本,所以它具有面向对象编程语言的一切特性,比如封装性、继承性、多态性等等,这就解决了刚才谈到的ASP的那些弱点。
作者:
变相怪杰
时间:
2015-3-20 09:25
Request:从字面上讲就是“请求”,因此这个是处理客户端提交的东东的,例如Resuest.Form,Request.QueryString,或者干脆Request("变量名")
欢迎光临 仓酷云 (http://ckuyun.com/)
Powered by Discuz! X3.2