如何访问我的control.cs中的按钮 [英] How to access a button in my control.cs

查看:74
本文介绍了如何访问我的control.cs中的按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

vew.aspx中有一个按钮.我想访问ControlModel.cs中的该按钮.但是应用程序的设计方式是,它们彼此之间都不了解.如何访问控件类中的按钮.

There is a button in vew.aspx . I want to access that button in my ControlModel.cs . But the application is designed in a way that they both have no knowledge of each other . How can I access the button in my Control class.

推荐答案

首先将一个变量声明为对象Globaly.

并在view.cs中写为-

对象b;
但是,对象;

foreach(this.Controls()中的对象b)
{
如果(TypeOf(b)==按钮)
{
但是Button = CType(b,Button);
//在这里传递,但传递给全局变量.如果ur变量是butctrl,则
butctrl =但是
}
}

现在在ControlModel.cs中
您可以从view.aspx中将butctrl作为您的按钮.
First declare one variable as object Globaly.

and write in view.cs as--

object b;
object but;

foreach(object b in this.Controls())
{
if (TypeOf(b) == Button)
{
but Button = CType(b, Button);
// here pass but to global variable. if ur variable is butctrl then
butctrl=but
}
}

Now in ControlModel.cs
u can get butctrl as ur button from view.aspx.


这篇关于如何访问我的control.cs中的按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆