Accessing controls over an ASP.NET Page in an other project

  • Thread starter Thread starter maarif
  • Start date Start date
M

maarif

The controls placed over an ASP.NET page can be accessed using
following loop:
For Each lControl In Page.Controls
. . . .
. . . .
Next
BUT this works only in code behind of that particular page.

I have another project where I need all these controls BUT not like
above loop. I want to access these controls like attributes of a class
as follows:

MyPage.Text1.Text = "100"
MyPage.Text2.Text = "200"
MyPage.Text3.Text = CInt(MyPage.Text1.Text) + CInt(MyPage.Text2.Text)

Is there any way to access the controls of an ASP.NET page?
 
The controls placed over an ASP.NET page can be accessed using
following loop:
For Each lControl In Page.Controls
. . . .
. . . .
Next
BUT this works only in code behind of that particular page.

I have another project where I need all these controls BUT not like
above loop. I want to access these controls like attributes of a class
as follows:

MyPage.Text1.Text = "100"
MyPage.Text2.Text = "200"
MyPage.Text3.Text = CInt(MyPage.Text1.Text) + CInt(MyPage.Text2.Text)

Is there any way to access the controls of an ASP.NET page?

Hi

HttpContext.Current.CurrentHandler

represents the current page what is executing...

cast it to your concrete page class

and access the controls...

for this you can expose your controls as public properties...

Best of luck

Munna
www.munna.shatkotha.com
www.munna.shatkotha.com/blog
www.shatkotha.com
 
Back
Top