Referencing web page in separate code file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a standard aspx page format that I replicate in many places on my site. That page has a lengthy page_load section, that I'd love to stick in a single code file (e.g. MyFunctions.vb). I know how to do this for simple functions such where I pass in and get back string parameters etc, but the code I want to stick in that code file includes commands to modify controls on the aspx page (e.g. label.text = "hello"). Can anyone tell me how to pass the name of the aspx page from the aspx page to the code file, and reference/modify controls on the aspx page from the code file? The scenario is:

Page1.aspx - page_load includes MyFunctions.InitializeLabels("page1.aspx")
Page2.aspx - page_load includes MyFunctions.InitializeLabels("page2.aspx")
MyFunctions.vb -
class MyFunctions
public shared function InitializeLabels
...commands like CallingPage.Label1.text = "Hello, World"
 
Hi,

a) consider using OO approch and create your own Page base class. this
class can implement your code and all derived Pages will use your code.

b) HttpContext.Current.Handler reference to the request IhhtpHandler
which is the calling Page.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
 
Back
Top