繁体   English   中英

从asp.net c#中的类访问单击事件和aspx页面的控制

[英]access click event and control of aspx page from class in asp.net c#

我正在使用asp.net,并且有一些页面在.cs中使用相同的代码。我想将此类代码(例如事件)移动到单独的类中,如何从类中访问.aspx页面控件和事件单击? (我现在使用该物业)

这是链接aspx: 链接

aspx.cs: 链接

class.cs 链接

我也遇到了这个问题。 您必须定义正在加载的当前页面。

protected void Page_Load(object sender, EventArgs e)
    {
        Page page = new Page(); //I think it is Page control. I am not sure right now, I dont have access to the code I made for that right now. But you propably get the main idea.
        page=this;
        Label c = new Label();
        c= Label1; //Might be c= this.Label1      
    } 

然后从课堂上您可以执行以下操作:

page.c.Text="I found you";

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM