S
Support
Hello:
I have the following code that currently needs to go in every page.
QUESTION 1) Can Page_Preinit go somewhere else more global like Global.asax
so that I dont have to copy this code in every page
QUESTION 2) How can I externalize this code, ie, can I create a class ?...
some external code that would be located in one location only for ease of
maintenance that each page could call ? IF so, please describe in detail.
Thanks
Public Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs)
Dim page As Page
page = DirectCast(sender, Page)
If Session("ScreenResolution") = "" Then
Session("path") = Request.Path
Response.Redirect("/Internals/Templates/detectscreen.aspx")
End If
If Session("ScreenResolution") = "800" Then
page.MasterPageFile = "/Internals/Templates/800MasterPage.master"
Else
page.MasterPageFile = "/Internals/Templates/1024MasterPage.master"
End If
End Sub
I have the following code that currently needs to go in every page.
QUESTION 1) Can Page_Preinit go somewhere else more global like Global.asax
so that I dont have to copy this code in every page
QUESTION 2) How can I externalize this code, ie, can I create a class ?...
some external code that would be located in one location only for ease of
maintenance that each page could call ? IF so, please describe in detail.
Thanks
Public Sub Page_PreInit(ByVal sender As Object, ByVal e As EventArgs)
Dim page As Page
page = DirectCast(sender, Page)
If Session("ScreenResolution") = "" Then
Session("path") = Request.Path
Response.Redirect("/Internals/Templates/detectscreen.aspx")
End If
If Session("ScreenResolution") = "800" Then
page.MasterPageFile = "/Internals/Templates/800MasterPage.master"
Else
page.MasterPageFile = "/Internals/Templates/1024MasterPage.master"
End If
End Sub