tags:

views:

17

answers:

2

I have a asp Textbox control in my .aspx page. I have a .cs class file , not the code behind file. I want to access this textbox control in this .cs file. I know I can pass it as a parameter.But I'm curious to know if I can do it through some reference way or something.

A: 

Only as parameter or from code behind class.. Seems no other way

nitropropain
A: 

There is another scenario.

If you have a .cs page like BasePage.cs that inherits from System.Web.UI.Page, and if your code-behind class inherits from this BasePage, then in the BasePage.cs you can gen a reference to your textbox through FindControl:

TextBox txtName = (TextBox)this.FindControl("txtName");

But in a totally unrelated class it's as you suspected, the only way is to pass it as a parameter.

Dan Dumitru