各位大虾们,请进来指教下,一个怪异的发毛的(C#)问题……

伴老思源 2005-08-18 01:44:41
请问有没有人遇到过事件错位的事,
问题:
在一个页中放置了多个按钮(假设按钮A,B,C,D),并对按钮写了相应的事件,编已通过后,再该页无论点A,B,C,D按钮都只执行按钮A的事件(放断点观察到的结果),在Web 窗体设计器生成的代码中也都有相应的事件,新建一页重做,结果不变,晕……

请各位大虾多多指教……
多出主意……
分不够可再加……
...全文
319 33 打赏 收藏 转发到动态 举报
写回复
用AI写文章
33 条回复
切换为时间正序
请发表友善的回复…
发表回复
cw888 2005-08-25
  • 打赏
  • 举报
回复
你看看是否下面的映射方法指向同一个:
this.Button1.Click += new System.EventHandler(this.Button1_Click);
liefeng123 2005-08-23
  • 打赏
  • 举报
回复
我遇到过这样的问题

InitializeComponent()方法丢了
little_iwf 2005-08-22
  • 打赏
  • 举报
回复
我还没有碰到这种问题
记下了
little_iwf 2005-08-22
  • 打赏
  • 举报
回复
我还没有碰到这种问题
记下了
伴老思源 2005-08-22
  • 打赏
  • 举报
回复
To: hchxxzx(NET?摸到一点门槛)
此方法也试过,还是不行,……
victor_liu 2005-08-19
  • 打赏
  • 举报
回复
事件绑定确实有丢失的现象,我在使用DataGrid碰到过
伴老思源 2005-08-19
  • 打赏
  • 举报
回复
自己顶一下
伴老思源 2005-08-19
  • 打赏
  • 举报
回复
我还没有执行,刚打开页面就这样,
但我加上,执行效果不变
eyych 2005-08-19
  • 打赏
  • 举报
回复
InitializeComponent()方法呢?
怎么没有????
伴老思源 2005-08-19
  • 打赏
  • 举报
回复
To: whispers(e代小生)
已经一天了,不知重起过多少次Vs了……,郁闷呀
伴老思源 2005-08-19
  • 打赏
  • 举报
回复
To: whispers(e代小生)
已经一天了,不知重起过多少次Vs了……,郁闷呀
whispers 2005-08-19
  • 打赏
  • 举报
回复
多重启VS试试
伴老思源 2005-08-19
  • 打赏
  • 举报
回复
//
// #region 弹出模态窗口 _DefaultSet( int BuyApplicationID )
// private void _DefaultSet( int BuyApplicationID )
// {
//// UpdateBasic.Attributes["onclick"] = "UpdateBasicInfo( '"+ BuyApplicationID +"' );";//返回调用前台的js
// }
// #endregion
//
// #region 判断当前申请单的状态并做出相应的页面初始化操作 _JudgePageSet()
// private void _JudgePageSet()
// {
// //判断当前申请单的状态
// CnIcp.Class._Buy This_Buy = new CnIcp.Class._Buy();
// int nState = 0;
// string strRefuseReason;
// This_Buy._GetBuyApplicationStateByNow( out strMessage, BuyApplicationID, out nState, out strRefuseReason );
// if( strMessage != "" )
// {
// ResponseEnd_MessageBox( strMessage );
// }
// if( nState != 0 )
// {
// State = Convert.ToInt32( nState );
// if( State == 2 )//被拒绝,初始化重新申请按钮,同时显示拒绝原因
// {
// bRePassApp.Visible = true;//重新申请按钮
//// bDel.Visible = true;
// if( strRefuseReason != "" ) //显示拒绝原因
// {
//// RefuseReason.Visible = true;
//// txtRefuseReason.Visible = true;
//// Reasontxt = strRefuseReason.ToString();
//// txtRefuseReason.InnerHtml = Convert.ToString( Reasontxt );
// }
// }
// if( State == 1 )//被批准
// {
// bRePassApp.Visible = false;
//// bDel.Visible = true;
// }
// }
// else
// {
// if( State == 0 )
// {
// bRePassApp.Visible = false;
//// bDel.Visible = true;
// }
// }
// }
// #endregion
//
// #region 在页面上初始化数据并绑定 _BasicSet()
// private void _BasicSet()
// {
//// string BuyAppPerson = ""; //采购申请人
//// string BuyAppDate = ""; //采购申请日期
//// float BuyAppPrice = 0; //拟购价
//// string IsSee = ""; //单据状态
//// string BuyAppReason = ""; //采购申请原因
//// string MoneyType = ""; //货币类型
////
//// CnIcp.Class._Buy This_Buy = new CnIcp.Class._Buy();
//// This_Buy._GetBuyApplicationBasic( out strMessage, BuyApplicationID, out BuyAppPerson, out MoneyType, out BuyAppDate, out BuyAppPrice, out IsSee, out BuyAppReason );
////
//// if( strMessage != "" )
//// {
//// ResponseEnd_Write( strMessage );
//// }
//// else
//// {
//// ResponseJavascript( "window.returnValue='true';" );
//// }
//// if( BuyAppPerson == "" )
//// {
//// ResponseEnd_Write( strMessage );
//// }
//// else
//// {
//// BuyAppPerson1.InnerHtml = Convert.ToString( BuyAppPerson );
//// }
//// if( BuyAppDate == "" )
//// {
//// AppDate1.InnerHtml = "无".ToString();
//// }
//// else
//// {
//// AppDate1.InnerHtml = Convert.ToString( Convert.ToDateTime( BuyAppDate ).ToShortDateString() );
//// }
//// if( MoneyType == "" )
//// {
//// MoneyType1.InnerHtml = "未指定".ToString();
//// }
//// else
//// {
//// MoneyType1.InnerHtml = Convert.ToString( MoneyType );
//// }
//// if( BuyAppPrice == 0 )
//// {
//// nprice1.InnerHtml = "0".ToString();
//// }
//// else
//// {
//// nprice1.InnerHtml = Convert.ToSingle( BuyAppPrice ).ToString();
//// }
//// if( IsSee == "" )
//// {
//// BillType1.InnerHtml = "未判断".ToString();
//// }
//// else
//// {
//// BillType1.InnerHtml = Convert.ToString( IsSee );
//// }
////
//// Reason1.InnerHtml = Convert.ToString( BuyAppReason );
// }
// #endregion
//
// #region Grid数据绑定 GridBuyApplicationListBind()
// private void GridBuyApplicationListBind()
// {
// CnIcp.Class._Buy This_Buy = new CnIcp.Class._Buy();
// GridBuyApplicationList.DataSource = This_Buy._GetOneBuyApplication_List( out strMessage, BuyApplicationID );
// if( strMessage != "" )
// {
// ResponseEnd_Write( strMessage );
// }
// GridBuyApplicationList.DataBind();
// }
// #endregion

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

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

}
#endregion

private void bRePassApp_ServerClick(object sender, System.EventArgs e)
{
Response.Write( "重新申请" );
Response.End();
}

private void bDel_ServerClick(object sender, System.EventArgs e)
{
Response.Write( "删除单据" );
Response.End();
}
}
}
伴老思源 2005-08-19
  • 打赏
  • 举报
回复
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;

namespace CnIcp.Aspx.Buy
{
/// <summary>
/// Buy_BuyNeed_ListDetail3 的摘要说明。
/// </summary>
public class Buy_BuyNeed_ListDetail3 : CnIcp._Global_Class._Page
{
protected System.Web.UI.HtmlControls.HtmlButton bRePassApp;
protected System.Web.UI.HtmlControls.HtmlButton bDel;

// protected System.Web.UI.WebControls.DataGrid GridBuyApplicationList;
// private int BuyApplicationID; //申请基本单ID
// private int State; //单据总状态
// private string Reasontxt ;
// protected System.Web.UI.HtmlControls.HtmlButton bRePassApp;
// protected System.Web.UI.HtmlControls.HtmlButton bDel; //拒绝原因
// private int IsDealed = -1; //是否被应用为采购单
//
private void Page_Load(object sender, System.EventArgs e)
{
Response.Expires = 0;
strFunctionPath = "采购管理/管理采购申请";
// if( Request.QueryString["BID"] == null )
// {
// ResponseEnd_Write( "非法的请求" );
// }
// else
// {
// BuyApplicationID = Convert.ToInt32( Request.QueryString["BID"] );
// if( !IsPostBack )
// { //初始化页面按钮
// bRePassApp.Visible = false; //重新申请按钮(只有当单据被拒绝时有效)
//// RefuseReason.Visible = false; //拒绝原因的title(只有当单据被拒绝时才显示)
//// txtRefuseReason.Visible = false; //拒绝原因的value(只有当单据被拒绝时才显示)
// bDel.Visible = false; //删除按钮(只要单据中的库存信息没有被应用为采购单,则一直有效)
// }
// _DefaultSet( BuyApplicationID ); //触发弹出模态窗口事件
// _JudgePageSet(); //判断当前申请单的状态并做出相应的页面初始化操作
// _BasicSet(); //在页面上初始化数据并绑定
// GridBuyApplicationListBind(); //Grid数据绑定
// _JudgeIsBuiedForBuyApplicationList(); //判断是采购申请单中的库存信息是否被应用为采购单
// }
}

// #region 判断是采购申请单中的库存信息是否被应用为采购单 _JudgeIsBuiedForBuyApplicationList()
// private void _JudgeIsBuiedForBuyApplicationList()
// {
// CnIcp.Class._Buy This_Buy = new CnIcp.Class._Buy();
// int nIsDealed = -1;
// This_Buy._JudgeIsBuiedForBuyApplicationList( out strMessage, BuyApplicationID, out nIsDealed );
// if( strMessage != "" ) ResponseEnd_MessageBox( strMessage );
// if( nIsDealed != -1 )
// {
// IsDealed = Convert.ToInt32( nIsDealed );
//
// //判断库存信息的状态:是否被应用为采购单
// if( IsDealed == 0 )
// {
// bDel.Visible = true;//显示删除单据按钮
// }
// if( IsDealed == 1 ) //当库存信息中有一条或多条被应用为采购单时(包括采购单执行后)
// {
// bDel.Visible = false;//隐藏删除单据按钮
// }
// }
// }
// #endregion
伴老思源 2005-08-19
  • 打赏
  • 举报
回复
To:fayewang(飞狐)
加了,四个按钮的事件全有……

To: lovefootball(蟑螂)
这我试过了,我删除了原来页,重新写了一编,每次都是双击按钮触发事件,再写入的,还是不行
zerory 2005-08-19
  • 打赏
  • 举报
回复
你的去看看BUTTON属性里面的事件 是否对应了相同的触发事件
正如楼上所说 BUTTON事件自己添加是不可以的
hchxxzx 2005-08-19
  • 打赏
  • 举报
回复
你把你上述的代码里面,如下两行删除
this.bRePassApp.ServerClick += new System.EventHandler(this.bRePassApp_ServerClick);
this.bDel.ServerClick += new System.EventHandler(this.bDel_ServerClick);
把对应的事件也删除
然后返回到ASPX页面,双击此两个按钮,让它们重新生成事件,你不要自己写这个事件,一定要自动生成.
然后再试试看.
sunny1979 2005-08-19
  • 打赏
  • 举报
回复
就是事件丢失把~
dapanda 2005-08-18
  • 打赏
  • 举报
回复
把代码贴出来,再把电脑砸了。
pontus 2005-08-18
  • 打赏
  • 举报
回复
没遇到过
加载更多回复(13)
你想当“李逍遥”式的“大侠”吗? 这里无需计算机基础,无需编程经验,你也不必是计算机专业的在校大学生....只要爱好游戏,怀揣梦想! 有一定自主学习能力,跟着刘老师从“编程小白”修炼为游戏研发“大虾”吧!!!学习好Unity,其先决条件是一定要有稳固、扎实的编程基础!课程 《C# For Unity系列之入门篇》配套学习资料链接:http://pan.baidu.com/s/1gflxreN 密码:sou5;刘老师讲Unity学员群(2) 497429806一、热更新系列(技术含量:中高级):A:《lua热更新技术中级篇》https://edu.csdn.net/course/detail/27087B:《热更新框架设计之Xlua基础视频课程》https://edu.csdn.net/course/detail/27110C:《热更新框架设计之热更流程与热补丁技术》https://edu.csdn.net/course/detail/27118D:《热更新框架设计之客户端热更框架(上)》https://edu.csdn.net/course/detail/27132E:《热更新框架设计之客户端热更框架(中)》https://edu.csdn.net/course/detail/27135F:《热更新框架设计之客户端热更框架(下)》https://edu.csdn.net/course/detail/27136二:框架设计系列(技术含量:中级): A:《游戏UI界面框架设计系列视频课程》https://edu.csdn.net/course/detail/27142B:《Unity客户端框架设计PureMVC篇视频课程(上)》https://edu.csdn.net/course/detail/27172C:《Unity客户端框架设计PureMVC篇视频课程(下)》https://edu.csdn.net/course/detail/27173D:《AssetBundle框架设计_框架篇视频课程》https://edu.csdn.net/course/detail/27169三、Unity脚本从入门到精通(技术含量:初级)A:《C# For Unity系列之入门篇》https://edu.csdn.net/course/detail/4560B:《C# For Unity系列之基础篇》https://edu.csdn.net/course/detail/4595C: 《C# For Unity系列之中级篇》https://edu.csdn.net/course/detail/24422D:《C# For Unity系列之进阶篇》https://edu.csdn.net/course/detail/24465四、虚拟现实(VR)与增强现实(AR):(技术含量:初级)A:《虚拟现实之汽车仿真模拟系统 》https://edu.csdn.net/course/detail/26618五、Unity基础课程系列(技术含量:初级) A:《台球游戏与FlappyBirds—Unity快速入门系列视频课程(第1部)》 https://edu.csdn.net/course/detail/24643B:《太空射击与移动端发布技术-Unity快速入门系列视频课程(第2部)》https://edu.csdn.net/course/detail/24645 C:《Unity ECS(二) 小试牛刀》https://edu.csdn.net/course/detail/27096六、Unity ARPG课程(技术含量:初中级):A:《MMOARPG地下守护神_单机版实战视频课程(上部)》https://edu.csdn.net/course/detail/24965B:《MMOARPG地下守护神_单机版实战视频课程(中部)》https://edu.csdn.net/course/detail/24968C:《MMOARPG地下守护神_单机版实战视频课程(下部)》https://edu.csdn.net/course/detail/24979

62,072

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧