首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

asp.net 按钮有关联到事件,点击时却不执行解决办法

2012-01-30 
asp.net 按钮有关联到事件,点击时却不执行前台: %@ControlLanguage c# AutoEventWireup false Code

asp.net 按钮有关联到事件,点击时却不执行
前台: <%@   Control   Language= "c# "   AutoEventWireup= "false "   Codebehind= "user_left.ascx.cs "   Inherits= "online_live.user.user_left "   TargetSchema= "http://schemas.microsoft.com/intellisense/ie5 "%>
<table   width= "208 "   height= "335 "   cellspacing= "0 "   bgcolor= "#efefe7 "   border= "1 ">
<TBODY>
<tr   height= "40% ">
<td   valign= "top ">
<table   width= "100% "   height= "160 "   border= "1 ">
<tr>
<td   height= "31 "   colspan= "2 "   align= "center "   background= "img/gaobei_shardh.gif "> 站内搜索 </td>
</tr>
<tr>
<td   colspan= "2 "   align= "center "> 请输入你要搜索的内容 </td>
</tr>
<tr>
<td   align= "right "   width= "83 "   valign= "top "   style= "WIDTH:   83px;   HEIGHT:   37px ">
关键字:
</td>
<td   style= "HEIGHT:   37px "> <form   name= "form6 "   method= "post "   action= " ">
&nbsp;
<asp:TextBox   id= "gjz "   runat= "server "   Width= "96px "> </asp:TextBox>
</form>
</td>
</tr>
<tr>
<td   align= "center "   colspan= "2 ">
&nbsp;
<asp:Button   id= "search "   runat= "server "   Text= "搜索 "> </asp:Button>
</td>
</tr>
</table>
<table   width= "100% "   height= "160 "   border= "1 ">
<tr>
<td   colspan= "2 "   align= "center "> 个人资料 </td>
</tr>
<tr>
<td   align= "right "> 用户名: </td>
<td>
<asp:Label   id= "yhm "   runat= "server "   Width= "59px "> </asp:Label> </td>
</tr>
<tr>
<td   align= "right "> 年龄: </td>
<td>
<asp:Label   id= "age "   runat= "server "   Width= "56px "> </asp:Label> </td>
</tr>
<tr>
<td   colspan= "2 "   align= "center "> <a   href= "user_info.aspx "> 更改我的资料 </a> </td>
</tr>
<tr>
<td   colspan= "2 "   align= "center "> 上传我的视频 </td>
</tr>
<tr>
<td   colspan= "2 "   align= "center "> 查看我的视频 </td>
</tr>
</table>
</td>
</tr>
</TBODY>
</table>
后台代码:
namespace   online_live.user
{
using   System;
using   System.Data;
using   System.Drawing;
using   System.Web;
using   System.Web.UI.WebControls;
using   System.Web.UI.HtmlControls;



///   <summary>
///user_left   的摘要说明。
///   </summary>
public   class   user_left   :   System.Web.UI.UserControl
{
protected   System.Web.UI.WebControls.TextBox   gjz;
protected   System.Web.UI.WebControls.Label   yhm;
protected   System.Web.UI.WebControls.Button   search;
protected   System.Web.UI.WebControls.Label   age;

private   void   Page_Load(object   sender,   System.EventArgs   e)
{
if(!this.IsPostBack)
{
yhm.Text=Session[ "yh "].ToString();
}
}

#region   Web   窗体设计器生成的代码
override   protected   void   OnInit(EventArgs   e)
{
//
//   CODEGEN:   该调用是   ASP.NET   Web   窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}

///   <summary>
///设计器支持所需的方法   -   不要使用代码编辑器
///修改此方法的内容。
///   </summary>
private   void   InitializeComponent()
{
this.search.Click   +=   new   System.EventHandler(this.search_Click);
this.Load   +=   new   System.EventHandler(this.Page_Load);

}
#endregion

private   void   search_Click(object   sender,   System.EventArgs   e)
{
        Session[ "search "]=gjz.Text;
Response.Redirect( "user_search.aspx ");
}


}
}

就是我按下搜索的时候,没有任何反映,但我在VS2003环境下点击按钮,它却有关联到事件!

[解决办法]
看代码没什么问题,你怎么知道没执行?
[解决办法]
vs2003经常丢事件,你在aspx界面重新选择下按钮的事件就行了

热点排行