Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/340.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何从另一个用户控件调用usercontrols事件_C#_Asp.net_User Controls - Fatal编程技术网

C# 如何从另一个用户控件调用usercontrols事件

C# 如何从另一个用户控件调用usercontrols事件,c#,asp.net,user-controls,C#,Asp.net,User Controls,我有用户控件A和用户控件B。如何在用户控件B中注册事件以使其被触发?。看起来控件A正在做一些事情,不允许用户控件B中的事件被触发 MyControlA.ascx.cs MyControlB.ascx.cs //need to fire this when checkbox of this user control is clicked. //but it seems MyControlA.ascx.cs which uses user control B is causing so

我有用户控件A和用户控件B。如何在用户控件B中注册事件以使其被触发?。看起来控件A正在做一些事情,不允许用户控件B中的事件被触发

MyControlA.ascx.cs


MyControlB.ascx.cs

  //need to fire this when checkbox of this user control is clicked.
  //but it seems MyControlA.ascx.cs which uses user control B is causing something that
  //does not allow this to get fired.
  protected void myCheckBox_CheckedChanged(object sender, EventArgs e)
   {
            //SOME CODE HERE
   }

在使用它的网页中注册用户控件B的事件。 在使用它的网页中注册用户控件A的事件

然后,当控件A触发事件时,您的网页将捕获它。一旦捕捉到它,在用户控件B中触发事件


将您的网页用作将两个用户控件组合在一起的中间类。

您的事件处理程序在MyControlB中吗?MyControlB上的复选框是吗?是的,这正是设置-但是MyControlA注册它MyControlA将事件注册到处理程序?对的如果是这样的话,你能发布你是如何注册处理程序的吗?它是这样注册的,嗯?这与myCheckBox\u CheckedChanged有什么关系?