这个问题困扰了我很久,网上也没什么答案.
在html网页中很容易实现像类似hao123网中那样的多邮箱登陆和百度搜索条,但是在aspx(c#)网页中很难实现.因为在涉及到JavaScript在aspx页面中的调用.
在aspx页面中使用百度搜索条时,搜索结果是乱码或者是繁体字,不知道什么原因,现在毕业设计要用到这两项功能,请各路高手亮出你的绝招~~~!
最好能给我一段能运行的代码,谢谢啦~!
出好主意的也给高分~!
在html网页中很容易实现像类似hao123网中那样的多邮箱登陆和百度搜索条,但是在aspx(c#)网页中很难实现.因为在涉及到JavaScript在aspx页面中的调用.
在aspx页面中使用百度搜索条时,搜索结果是乱码或者是繁体字,不知道什么原因,现在毕业设计要用到这两项功能,请各路高手亮出你的绝招~~~!
最好能给我一段能运行的代码,谢谢啦~!
出好主意的也给高分~!
Javascript与aspx的相互调用可以参考我的blog
cnblogs.com/tengs2000
百度的编码是gb2312而web.config里的默认编码是
<globalization
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
后台代码为即直接讲页面编码变为gb2312:
private void InitializeComponent()
{
this.Init+=new EventHandler(baidu_Init)
}
private void baidu_Init(object sender,System.EventArgs e)
{
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
}
建了个新页面
在前台代码中:
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server" target="result">
<FONT face="宋体"></FONT>
<TBODY>
<tr>
<td>
<asp:TextBox ID="text1" Runat="server" Width="95px" Height="22"></asp:TextBox>
<asp:Button ID="btn" Text="百度搜索" Runat="server" Width="72px" Height="24"></asp:Button>
</td>
</tr>
</form>
</body>
后台的代码即Button的Click事件为:
private void btn_Click(object sender, System.EventArgs e)
{
Response.Redirect("http://www.baidu.com/s?wd="+text1.Text+"&cl=3");
}
<table width="468" border="1" cellspacing="0" cellpadding="0" bordercolorlight="#000000" bordercolordark="#FFFFFF" align="center">
<tr>
<td><table width=468 height="45" border=0 cellpadding=0 cellspacing=0 bgcolor="f7f7f7">
<form action=http://www1.baidu.com/baidu target=_blank>
<tbody>
<tr>
<td width="30%" rowspan="2"> <div align=center><a href="http://www.baidu.com/index.php?tn=sitesowang" target=_blank>
<img alt=百度中文搜索引擎 border=0 src="http://img.baidu.com/images/ss_logo.gif"></a></div></td>
<td valign=bottom width="70%"> <div align=center>
<table align=right border=0 cellpadding=0 cellspacing=0 width="100%">
<tbody>
<tr>
<td><font color="#666666" style="FONT-SIZE: 12px">全球最大的中文信息库,一定有你想要的...</font><font color="#666666" style="FONT-SIZE: 12px"> </font><A
href="http://union.baidu.com/paihang/index.php"
target=_blank><font style="font-size: 12px" color="#ff0000">网站排行榜</font></A></td>
</tr>
</tbody>
</table>
</div></td>
</tr>
<tr>
<td valign=bottom><font style="FONT-SIZE: 12px">
<input id=word name=word size="38" value="请输入关键字" onMouseOver="this.focus()" onBlur="if (value ==''){value='请输入关键字'}" onFocus="this.select()" onClick="if(this.value=='请输入关键字')this.value=''">
</font> <input align=middle border=0 height=17 id=image name=image src="http://img.baidu.com/img/go.gif" type=image width=30>
<font style="FONT-SIZE: 12px"> <a href="http://union.baidu.com/paihang/index.php" target=_blank></a><a href="http://union.baidu.com/paihang/index.php" target=_blank></a>
<input id=tn name=tn type=hidden value=sitesowang>
</font></td>
</tr>
</form>
</table></td>
</tr>
</table><img src= http://un.baidu.com/images/st.gif?tn=sitesowang width=0 height=0>
2. google的:
<center>
<FORM method=GET action="http://www.google.com/search" target="_blank">
<TABLE bgcolor="#FFFFFF" style="border:1px solid #000000"><tr><td>
<A HREF="http://www.google.com/intl/zh-CN/" target="_blank">
<IMG SRC="http://www.google.com/logos/Logo_40wht.gif"
border="0" ALT="Google" align="absmiddle"></A>
<INPUT TYPE=text name=q size=31 maxlength=255 value="">
<INPUT TYPE=hidden name=hl value=zh-CN>
<INPUT type=submit name=btnG value="Google搜索">
</td></tr></TABLE>
</FORM>
</center>
requestEncoding="utf-8"
responseEncoding="utf-8" />
我用的是VS2005+Ajax;
是什么问题呢?
Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312"); 就可以了.
自己手动在web.config里面配置···手写代码·
如果是在baidu上显示的结果那我就晕
在web.config里(在<system.web>和</system.web>标记之间)手动添加一条内容即可:
<globalization requestEncoding="gb2312" responseEncoding="gb2312" />二,还没有解决的问题: 在asp.net中实现多邮箱登陆功能,和www.hao123.com上面的功能一样。
期待高手指点迷津,本人是新手,希望详细一点