Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp.net access a control from static function

I have a webform and in that webform, I am trying to access a Panel object from a static method, but couldn't access it How can I access a Panel object from static method. Why am I trying to access the object from static? Because I am using JQUERY which only accepts static methods.

I tried to store Panel in session in Page_Load() and retrieve it from static method but it didn't work.


1 Answers

public static void DoSomething()
{
    if (HttpContext.Current != null)
    {
        Page page = (Page)HttpContext.Current.Handler;
        TextBox TextBox1 = (TextBox)page.FindControl("TextBox1");

        TextBox TextBox2 = (TextBox)page.FindControl("TextBox2");
    }
}
like image 93
A Programmer Avatar answered May 30 '26 06:05

A Programmer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!