A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 钟广雄 中级黑马   /  2012-6-7 21:43  /  4167 人查看  /  3 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

本帖最后由 钟广雄 于 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>");

                }

评分

参与人数 1技术分 +2 收起 理由
宋天琪 + 2

查看全部评分

3 个回复

倒序浏览
建议你把你网页文件的文件字符编码改成UTF-8
和在head标签中加
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
响应回去的数据默认是Utf-8的编码

评分

参与人数 1技术分 +1 收起 理由
宋天琪 + 1

查看全部评分

回复 使用道具 举报
看一下你页面的编码格式!
回复 使用道具 举报
朱亮辉 发表于 2012-6-10 01:08
看一下你页面的编码格式!

HTML编码:<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

ashx 代码

  解决了,谢谢
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马