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

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?
 
M

Munna

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top