How to reference multiple webpages

I have a method in Session which populates text fields on a webpage with data from a database. This method is called from the webpage’s Open event (or Shown event). It works fine.

But, now I have created a mobile optimised webpage which will be displayed if Session.Platform is indicating a mobile device. I want to call this same method, but from this alternative webpage.

Trouble is the method explicitly populates the controls of the original webpage. I therefore want to create a variable which will point to the calling page.

So in my method, instead of a line like:-
Session.MyPage1.fldCustomerName.Text = datafield1.stringvalue

I want to state something like this…
varPage.fldCustomerName.Text = datafield1.stringvalue

Where varPage is a valid reference to the calling page. Goes without saying that all calling pages must contain a control called fldCustomerName, of course.

I have tried setting the calling page event to something like
Dim varPage as new MyPage1
Session.MethodGetData(varPage)

But the method fails to compile as varPage “does not exist”

Any ideas? Am I approaching this the wrong way?

You could put your pages as properties on the session class and reference them directly from session. The problem is you will need to go through your code and make sure that you only reference them from the session properties and not directly by name or else you will end up with two different pages.

I think there is a blog post or thread about the relative merits of implicit vs explicit instantiation of webpages. Google might turn it up.