Access main page properties

S

SOS

Hi guys,
i have a page and a user control wich placed on this page in my project.
i need to access some properties of this page from this user control,
how can i do that ?

Thanx
 
T

Teemu Keiski

Hi,

you use code-behind? Cast the Page property in user control into the
code-behind type of the Page in question. Then you can access the
properties. I.e

[VB]
CType(Page,[codebehindtype]).property

[C#]
(([codebehindtype])Page).property

Note that this of course makes the user control somewhat page-specific
unless you handle it say by checking if the Page is of correct type (of
course if this is intentional, it is different thing)
 
J

Jos

SOS said:
Hi guys,
i have a page and a user control wich placed on this page in my
project. i need to access some properties of this page from this user
control, how can i do that ?

Thanx

If these are properties of the Page object, you can just refer to Page:
e.g. Page.Server.MapPath(...)
Page.Request.QueryString(...)

If they are specific for your own page, see Teemu's answer.
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,818
Latest member
SapanaCarpetStudio

Latest Threads

Top