日期:2014-05-19  浏览次数:21173 次

按钮点击了没反映
<%@   Page   Language= "C# "   AutoEventWireup= "true "     CodeFile= "Default.aspx.cs "   Inherits= "_Default "   %>

<!DOCTYPE   html   PUBLIC   "-//W3C//DTD   XHTML   1.0   Transitional//EN "   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">

<html   xmlns= "http://www.w3.org/1999/xhtml "   >
<head   runat= "server ">
        <title> Untitled   Page </title>
</head>
<body>
        <form   id= "form1 "   runat= "server ">
        <div>
                <asp:TextBox   ID= "TextBox1 "   runat= "server "> </asp:TextBox>
                <asp:Button   ID= "Button1 "   runat= "server "   OnClick= "Button1_Click "   Text= "Button "   /> </div>
        </form>
</body>
</html>


using   System;
using   System.Data;
using   System.Configuration;
using   System.Web;
using   System.Web.Security;
using   System.Web.UI;
using   System.Web.UI.WebControls;
using   System.Web.UI.WebControls.WebParts;
using   System.Web.UI.HtmlControls;
using   System.Diagnostics;

public   partial   class   _Default   :   System.Web.UI.Page  
{
        protected   void   Page_Load(object   sender,   EventArgs   e)
        {
        }
        protected   void   Button1_Click(object   sender,   EventArgs   e)
        {
                if   (TextBox1.Text   !=   " ")
                        Process.Start(string.Format( "http://www.baidu.com/baidu?wd={0}&cl=3 ",   TextBox1.Text));      
        }
}


就一个TextBox和一个按钮,在TextBox输入数据后点按钮就使用百度搜索,但是现在
输入数据后点按钮没反映,把   if   (TextBox1.Text   !=   " ")   去掉也一样,这是为什么呢?


------解决方案--------------------
事件处理代理没有写好
------解决方案--------------------
Response.Redirect(string.Format( "http://www.baidu.com/baidu?wd={0}&cl=3 ", TextBox1.Text));
------解决方案--------------------
Response.redirect是页面重定向,如果要在新窗口中打开,用window.open()