本帖最后由 钟广雄 于 2012-6-7 21:44 编辑
html 表单代码
<form method="post" action="report.ashx" target="_self">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="90%">
<tbody>
<tr>
<td width="15%">网站名称:</td>
<td width="85%"><input name="webname" maxlength="6" id="网站名称" value="" type="text">
网站的连接名称(不超过六个字)</td>
</tr>
<tr>
<td>网站地址:</td>
<td><input name="weburl" id="网站地址" value="http://" type="text">
网站链接地址</td>
</tr>
<tr>
<td>收录分类:</td>
<td><strong>
<input name="webtype" id="收录分类" value="" type="text">
</strong> 依据贵站定位写明详细分类 如"音乐MP3-在线音乐"</td>
</tr>
<tr>
<td>PR值:</td>
<td><input name="webpr" id="Alexa排名" value="" type="text"></td>
</tr>
<tr>
<td>联系QQ:</td>
<td><strong>
<input name="qq" id="联系QQ" value="" type="text">
</strong></td>
</tr>
<tr>
<td>联系邮箱:</td>
<td><strong>
<input name="email" id="联系邮箱" value="" type="text">
</strong></td>
</tr>
<tr>
<td>是否已加友链:</td>
<td><input name="isfriend" value="1" checked="checked" type="radio">
是
<input name="isfriend" value="0" type="radio">
否 如未做链接将不予收录</td>
</tr>
<tr>
<td></td>
<td><label>
<input type=submit value="提交" />
</label></td>
</tr>
</tbody>
</table>
</form>
HTML编码:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
ashx 代码
web w = new web();
database db = new database();
public void ProcessRequest (HttpContext context) {
context.Response.ContentType = "text/html";
try
{
w.Webname =context.Server.HtmlDecode(context.Request.Form["webname"]);
w.Weburl = context.Request.Form["weburl"];
w.Webtype = context.Request.Form["webtype"];
w.Qq = Convert.ToInt32(context.Request.Form["qq"]);
w.Email = context.Request.Form["email"];
w.Isfriend = int.Parse(context.Request.Form["isfriend"]);
w.Webpr = int.Parse(context.Request.Form["webpr"]);
w.Time = DateTime.Now.ToShortTimeString();
if (db.Entry(w) > 0)
{
//context.Response.Redirect("index.html");
context.Response.Write("<script>alert('提交成功');history.go(-1)</script>");
}
|