全面OO asp,构造属于自己的WebForm对象!(实例)

效果图:http://blog.csdn.net/xiaoqy/gallery/image/4414.aspx

templates.js:http://blog.csdn.net/xiaoqy/archive/2004/07/16/43454.aspx

form.js: http://blog.csdn.net/xiaoqy/archive/2004/07/16/43457.aspx

basic.js: http://blog.csdn.net/xiaoqy/archive/2004/07/16/43459.aspx

form.asp

<%@ language="JSCRIPT" %>
<!--#include file="include/basic.js" -->
<!--#include file="include/template.js" -->
<!--#include file="include/form.js" -->
<%
//创建一个aspTemplate对象
var tpl = new aspTemplate();
tpl.setFile("file","form.tpl");
var form = new form("form");

//创建一个文本框对象
var input = new text();
input.Init('name',"HTTP_HOST");
input.setDesc("文本,密码,多行文本,隐藏");
input.setPattern("[0-9]");
form.addElement(input);

var f = new text();
f.Init("fffffffffffff","test");
form.addElement(f);

//创建一个选择列表对象
var s = new select();
s.Init("s","3");
s.setDesc("选择列表,单选,多选");
s.buildValue("a,b,c,d,e,f,g");
form.addElement(s);

//创建一个单选按钮对象
var r = new radio();
r.Init("r","a");
r.setDesc("单选按钮");
r.buildValue("a,b,c,d,e,f,g,h,j");
r.radioAssign(tpl,"file","</tr><tr>",3);
form.addElement(r);

//创建一个多选按钮对象
//调用其他被包含文件
tpl.setFile("otherfile","otherfile.tpl");

var c = new checkbox();
c.Init("c","a");
c.setDesc("选择框,单选,多选");
c.buildValue("a,b,c,d,e,f,g,h");
c.checkboxAssign(tpl,"otherfile","</tr><tr>",2);
form.addElement(c);
form.assignfortpl(tpl);

 

//解析输出主文件
tpl.parse("otherfiles","otherfile");
tpl.parse("main","file",true);
Response.write(tpl.p("main"));
//tpl.showall();
%>

模版:

form.tpl

<head>
<meta name="GENERATOR" content="SAPIEN Technologies PrimalScript 3.1">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Document Title</title>
</head>
<body>

<!-- Insert HTML here -->
<form action="form.asp" method="post" name="form">
<input type="text" name="name" value="{name_value}">
<input type="text" name="fffffffffffff" value="{fffffffffffff_value}">
<select name=s>{s_options_str}</select><BR>
<table border=1><tr>
<!-- BEGIN R -->
<td>
<input type=radio name="r" value="{value}" {checked}>{text}
</td>{broken}
<!-- END R -->
</tr>
</table>{otherfiles}
<input type="submit" value="submit">
</form>

{form_errormsg}
</body>
</html>

otherfile.tpl

<table border=1><tr>
<!-- BEGIN C -->
<td>
<input type=checkbox name="c" value="{value}" {checked}>{text}
</td> {broken}
<!-- END C -->
</tr>
</table>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值