Access main page properties

  • Thread starter Thread starter SOS
  • Start date Start date
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
 
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)
 
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.
 
Back
Top