仓酷云

标题: ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB... [打印本页]

作者: 深爱那片海    时间: 2015-1-16 22:08
标题: ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
ASP最大的缺点在于网络的安全性和可靠性,企业将经营数据放在开放的平台上,最大的担忧就是如何保证这些数据不被其他人破坏。假如刚从ASP过渡到ASPX的程序员,多数会埋怨ASPX天生的客户端元素的ID,太长了!假如要在客户端剧本中利用,如使用:
以下为援用的内容:
document.getElementById(Repeater1_ctl00_Button1)
这一类的体例来援用,十分不便利。

想像一下,你想天生如上的界面,然后在鼠标在Button上mousemove时,改动其后面对应的文本框中的笔墨,格局为:helloworld+该Button的ID+--+newDate().valueOf()
先不要管,这个有甚么用,在甚么中央用,起首,你怎样完成呢?
我的完成办法就是如题目所言,用服务器控件来凑合它们,只需我们来选择一个符合的思绪:假定我们有一个服务器控件,经由过程给控件指定两个相干联的控件(这里就是Buton和TextBox),我们在客户端为这两个控件,分离设置自界说的属性来间接指向另外一个控件。
假如有了另外一个控件的援用,我们就能够在button的实例中,间接失掉相干联的TextBox的援用,而绕开getElementById().
先看一下该服务端控件的利用:

以下为援用的内容:<div>
ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图
<asp:RepeaterID="Repeater1"runat="server">
<ItemTemplate>
<asp:TextBoxID="TextBox1"runat="server"Width="445px"></asp:TextBox>
<asp:ButtonID="Button1"runat="server"Text="Button"onmousemove="returnbutton_onmousemove(this,event)"/>
<cc1:WebControlLinkerID="WebControlLinker1"runat="server"WebControlFirst="Button1"WebControlSecond="TextBox1"/>
</ItemTemplate>
</asp:Repeater>

</div>
注重一下cc1:WebControlLinker的WebControlFirst="Button1"WebControlSecond="TextBox1"我们设置了两联系关系的控件.

它们会在页面输入时,天生上面的代码:
页面出现:

以下为援用的内容:<div>

<inputname="Repeater1$ctl00$TextBox1"type="text"id="Repeater1_ctl00_TextBox1"style="width:445px;"/>
<inputtype="submit"name="Repeater1$ctl00$Button1"value="Button"id="Repeater1_ctl00_Button1"onmousemove="returnbutton_onmousemove(this,event)"/>
<spanid="Repeater1_ctl00_WebControlLinker1"></span>

<inputname="Repeater1$ctl01$TextBox1"type="text"id="Repeater1_ctl01_TextBox1"style="width:445px;"/>
<inputtype="submit"name="Repeater1$ctl01$Button1"value="Button"id="Repeater1_ctl01_Button1"onmousemove="returnbutton_onmousemove(this,event)"/>
<spanid="Repeater1_ctl01_WebControlLinker1"></span>

<inputname="Repeater1$ctl02$TextBox1"type="text"id="Repeater1_ctl02_TextBox1"style="width:445px;"/>
<inputtype="submit"name="Repeater1$ctl02$Button1"value="Button"id="Repeater1_ctl02_Button1"onmousemove="returnbutton_onmousemove(this,event)"/>
<spanid="Repeater1_ctl02_WebControlLinker1"></span>

<inputname="Repeater1$ctl03$TextBox1"type="text"id="Repeater1_ctl03_TextBox1"style="width:445px;"/>
<inputtype="submit"name="Repeater1$ctl03$Button1"value="Button"id="Repeater1_ctl03_Button1"onmousemove="returnbutton_onmousemove(this,event)"/>
<spanid="Repeater1_ctl03_WebControlLinker1"></span>

<inputname="Repeater1$ctl04$TextBox1"type="text"id="Repeater1_ctl04_TextBox1"style="width:445px;"/>
<inputtype="submit"name="Repeater1$ctl04$Button1"value="Button"id="Repeater1_ctl04_Button1"onmousemove="returnbutton_onmousemove(this,event)"/>
<spanid="Repeater1_ctl04_WebControlLinker1"></span>


</div>
以下为援用的内容:<scripttype="text/javascript">
ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图

ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图
<!--
document.getElementById(Repeater1_ctl00_Button1).setAttribute(TextBox1,document.getElementById(Repeater1_ctl00_TextBox1));
document.getElementById(Repeater1_ctl00_TextBox1).setAttribute(Button1,document.getElementById(Repeater1_ctl00_Button1));
document.getElementById(Repeater1_ctl01_Button1).setAttribute(TextBox1,document.getElementById(Repeater1_ctl01_TextBox1));
document.getElementById(Repeater1_ctl01_TextBox1).setAttribute(Button1,document.getElementById(Repeater1_ctl01_Button1));
document.getElementById(Repeater1_ctl02_Button1).setAttribute(TextBox1,document.getElementById(Repeater1_ctl02_TextBox1));
document.getElementById(Repeater1_ctl02_TextBox1).setAttribute(Button1,document.getElementById(Repeater1_ctl02_Button1));
document.getElementById(Repeater1_ctl03_Button1).setAttribute(TextBox1,document.getElementById(Repeater1_ctl03_TextBox1));
document.getElementById(Repeater1_ctl03_TextBox1).setAttribute(Button1,document.getElementById(Repeater1_ctl03_Button1));
document.getElementById(Repeater1_ctl04_Button1).setAttribute(TextBox1,document.getElementById(Repeater1_ctl04_TextBox1));
document.getElementById(Repeater1_ctl04_TextBox1).setAttribute(Button1,document.getElementById(Repeater1_ctl04_Button1));
ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图
//-->
</script>
有了下面的器材,,我们要实行的剧本就能够复杂的写成如许:以下为援用的内容:
<head><title>
UntitledPage
</title>
ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图
ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图
<scripttype="text/javascript">
functionbutton_onmousemove(obj,e)
ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图
ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图
{
obj.TextBox1.value="helloworld"+obj.TextBox1.Button1.id+--+newDate().valueOf();;
ASP网站制作之用控件的体例办理成绩-在客户端联系关系WEB...
登录/注册后可看大图
}
</script>

</head>obj.TextBox1.value这类体例,会见,也挺爽吧?
请作者接洽本站,实时附注您的姓名,接洽邮箱:Post@chinaz.com。


ASP在国内异常流行,因为国内大多使用的是盗版的Windows和盗版的SQLServer,而ASP+COM+SQLServer实际上也是一种不错的搭配,其性能也不输于PHP+MYSQL,特别是Windows系统和SQLServer都有图形界面,比APACHE和MYSQL易于维护,因此对于不重视知识产权的国家来说也是一种不错的选择。
作者: 金色的骷髅    时间: 2015-1-18 21:02
跟学别的语言一样,先掌握变量,流程控制语句(就是ifwhileselect)等,函数/过程,数组
作者: 透明    时间: 2015-1-26 21:16
掌握asp的特性而且一定要知道为什么。
作者: 兰色精灵    时间: 2015-2-4 21:49
兴趣爱好,那么你无须学编程,申请一个域名和空间,在网上下载一些免费开源的CMS系统,你不用改代码,只须熟悉它们的后台操作,像office一样简单方便,很快就能建一个站点,很多站长都是这样做的
作者: 莫相离    时间: 2015-2-10 19:30
如何学好ASP,以前也有人问过,把回答给你转过来看看能否对你有帮助:
作者: 飘灵儿    时间: 2015-3-1 15:10
运用ASP可将VBscript、javascript等脚本语言嵌入到HTML中,便可快速完成网站的应用程序,无需编译,可在服务器端直接执行。容易编写,使用普通的文本编辑器编写,如记事本就可以完成。由脚本在服务器上而不是客户端运行,ASP所使用的脚本语言都在服务端上运行。
作者: 深爱那片海    时间: 2015-3-10 19:29
他的语法和设计思路和VB完全相同,导致很多ASP的书都留一句“相关内容请参考VB的相关教材....”更糟糕的是,相当多的ASP教程混合了Javascript,VBscript等等脚本语言,搞的初学者。
作者: 谁可相欹    时间: 2015-3-17 10:10
在平时的学习过程中要注意现学现用,注重运用,在掌握了一定的基础知识后,我们可以尝试做一些网页,也许在开始的时候我们可能会遇到很多问题,比如说如何很好的构建基本框架。
作者: 爱飞    时间: 2015-3-24 07:05
不是很难但是英文要有一点基础网上的教程很少有系统的详细的去买书吧,另不用专门学习vb关于vbscript脚本在asp教材都有介绍




欢迎光临 仓酷云 (http://ckuyun.com/) Powered by Discuz! X3.2