一个HTML页面是用户提交信息用的.
一直提交到new.aspx进行处理添加数据.可是从HTML传过来的都是乱码
HTML页代码:
- HTML code
<form name="referForm"action="new.aspx" method="post"> <span>发布标题:<input type="text" name="titletext" id="titletext" /><br></span> <span>信息分类:<select name="selectMenu" id="selectMenu" class="sel" onchange="MenuBin()"> <option value="-1">-请选择分类-</option> <option value="0">二手信息</option> <option value="1">综合服务</option> <option value="2">招聘求职</option> <option value="3">生活消费</option> <option value="4">教育培训</option> <option value="5">同城寻缘</option> <option value="6">公众信息</option> </select> <select name="selectClass" id="selectClass" class="sel"> <option value="-2" selected="selected">-请选择顶级分类-</option> </select><br></span> <span>地域位置:<select name="Address" id="Address" class="sel"> <option value="-1">请选择位置</option> <option value="1">武昌区</option> <option value="2">洪山区</option> <option value="3">江岸区</option> <option value="4">江汉区</option> <option value="5">汉阳区</option> <option value="6">硚口区</option> <option value="7">其他</option> </select><br></span> <span>联系地址:<input type="text" name="contact" id="contact" class="mytext" style="width:200px" /> <br></span> <span>有效天数:<input type="text" name="day" id="day" style="width:40px" onblur="erro()"/> <b id="dayerro" style="color:#FF0000; font-weight:normal; display:none; font-size:12px"><img src="images/erro.gif" />请正确输入天数!</b><br></span> <span class="com"><h style="float:left">信息内容:</h><textarea name="comment" id="comment" class="mytext" style="width:400px;height:100px"></textarea><br></span> <span class="com"><h style="float:left">联系方式:</h><textarea name="conttype" id="conttype" class="mytext" style="width:400px;height:100px">联系人:电话:邮箱:QQ:</textarea></span><Div class="btn"> <a href="javascript:Submit()"><img src="images/btn.gif" border="0"/></a></Div></form>
ASPX处理页面代码:
- C# code
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { Hashtable hash = new Hashtable(); SqlString sqltr = new SqlString(); hash.Add("InfoTitle",sqltr.GetQuotedString( Request.Params["titletext"].ToString()));//标题 hash.Add("InfoMenuId", sqltr.GetQuotedString(Request.Params["selectMenu"].ToString()));//一级分类ID hash.Add("InfoClassId", sqltr.GetQuotedString(Request.Params["selectClass"].ToString()));//二级分类ID hash.Add("InfoIP", sqltr.GetQuotedString(Request.UserHostAddress.ToString()));//获取用户IP地址 hash.Add("InfoLocal", sqltr.GetQuotedString(Request.Params["Address"].ToString()));//地理位置 hash.Add("InfoAddress", sqltr.GetQuotedString(Request.Params["contact"].ToString()));//联系地址 hash.Add("InfoDay", sqltr.GetQuotedString(Request.Params["day"]));//有效天数 hash.Add("InfoContace", sqltr.GetQuotedString(Request.Params["conttype"].ToString()));//联系方式 hash.Add("InfoComment", sqltr.GetQuotedString(Request.Params["comment"].ToString()));//信息内容 hash.Add("InfoTOP", 0);//是否置顶 hash.Add("InfoDate", sqltr.GetQuotedString(DateTime.Now.ToString()));//当前时间 User user = new User(); if (user.AddInfo(hash)) { Response.Redirect("default.aspx"); } } }