简体   繁体   中英

How to access controls from aspx file in other .cs files

I have a aspx file where controls are written. I want to access these controls in .cs file which is not code of this aspx file but another class file.

For example: I want to update an UpdatePanel from another .cs file.

How can I do this?

Just pass it as a parameter to the method in the other class file. Something like:

public class OtherClassFile
{
    public static void UpdateMethod(UpdatePanel panel)
    {
        //Update the panel here
    }
}

Then the methdod call in your .aspx page would look like this:

OtherClassFile.UpdateMethod(MyUpdatePanel);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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