CSDN博客

img XiaoQy

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

发表于2004/7/16 23:36:00  792人阅读

分类: Asp JScript

效果图: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

相关博文

我的热门文章

img
取 消
img