473,324 Members | 2,124 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

Problem enumerating pages in .NET 2.0

Without bothering with the details (though if you are curious, I'll be
glad to explain!). This code functions perfectly under ASP.NET 1.1, but
randomly fails under ASP.NET 2.0. More details after the snippet

My site has the following web pages:
MainPage.aspx
Page1.aspx
Page2.aspx
Page3.aspx
Page4.aspx

The code behind file for MainPage looks like this:

Partial Class FinOpsCentral
Inherits System.Web.UI.Page

Dim appPages As New Hashtable

Private Sub Page_Load ...
appPages.Add(butPage1, "Page1")
appPages.Add(butPage2, "Page2")
appPages.Add(butPage3, "Page3")
appPages.Add(butPage4, "Page4")

If (Not IsPostBack) Then
Dim aspxPageType As Type
For Each pageObject As DictionaryEntry In appPages
aspxPageType = Type.GetType(pageObject.Value)
Next
End If
End Sub

....

End Class

By 'randomly fails', the GetType function will return Nothing on one of
the pages. If the solution is recomplied, GetType will return Nothing
for a page that (prior to recompiling) it returned its type.

The only difference between the 2.0 code and the 1.1 code is this:
Under 1.1, the GetType line read:

aspxPageType = Type.GetType("siteName." +
pageObject.Value)

I make heavy use of this construct in a number of my applications. It
works just fine for one of them (which has about six pages), but fails
on the others (which have about a dozen pages).

I haven't a clue as to why this is failing - I could really use your
help! Thanks.

Mar 8 '06 #1
2 1339
in asp.net 1.1, the page codebehind files were built into one dll, and the
page (aspx code) dll referenced that dll thru inherence. this meant the
codebehind code of one page could reference the codebehind code of any page
as there are in the same dll.

in 2.0, the codebehind is compiled, thru partial classes into the page dll.
thus for a page to reference another page you have a couple options.

both 1.1 and 2.0 use a batch compile concept for pages, so several pages
are compiled into one dll. this is what causes your intermittent problems.
when the pages are compiled together it works, when a page gets it own dll
it doesn't.

1) use base pages in app dir and inherit (1.1 model).
2) use a utility to combine all page dll into one - requires custom build
step
3) if only one page needs references to others, just add a reference
directive in the aspx

-- bruce (sqlwork.com)

"Gerry" <ge***@pairofdocs.net> wrote in message
news:11**********************@u72g2000cwu.googlegr oups.com...
Without bothering with the details (though if you are curious, I'll be
glad to explain!). This code functions perfectly under ASP.NET 1.1, but
randomly fails under ASP.NET 2.0. More details after the snippet

My site has the following web pages:
MainPage.aspx
Page1.aspx
Page2.aspx
Page3.aspx
Page4.aspx

The code behind file for MainPage looks like this:

Partial Class FinOpsCentral
Inherits System.Web.UI.Page

Dim appPages As New Hashtable

Private Sub Page_Load ...
appPages.Add(butPage1, "Page1")
appPages.Add(butPage2, "Page2")
appPages.Add(butPage3, "Page3")
appPages.Add(butPage4, "Page4")

If (Not IsPostBack) Then
Dim aspxPageType As Type
For Each pageObject As DictionaryEntry In appPages
aspxPageType = Type.GetType(pageObject.Value)
Next
End If
End Sub

...

End Class

By 'randomly fails', the GetType function will return Nothing on one of
the pages. If the solution is recomplied, GetType will return Nothing
for a page that (prior to recompiling) it returned its type.

The only difference between the 2.0 code and the 1.1 code is this:
Under 1.1, the GetType line read:

aspxPageType = Type.GetType("siteName." +
pageObject.Value)

I make heavy use of this construct in a number of my applications. It
works just fine for one of them (which has about six pages), but fails
on the others (which have about a dozen pages).

I haven't a clue as to why this is failing - I could really use your
help! Thanks.

Mar 8 '06 #2
Bruce,

Thank you for you suggestions. Of the three options, I found the third
to be most agreeable as only one page needs to reference the others.
Thus, I modified the code in MainPage.aspx so that it now looks like
this:

<%@ Page Language="VB" AutoEventWireup="false"
CodeFile="MainPage.aspx.vb" Inherits="MainPage" %>
<%@ Reference Page="Page1.aspx" %>
<%@ Reference Page="Page2.aspx" %>
<%@ Reference Page="Page3.aspx" %>

etc.

Sadly, I am experiencing the same problem.

Did I not include the reference correctly?
Is there something else I forgot to do?

Thanks.

Mar 27 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Andrew Crowe | last post by:
Hi guys, I've come across a rather strange, and very anoying problem. On /some/ PHP sites that we're developing on 2 different servers, files that are in the root of the website are unable to...
10
by: Brent | last post by:
Hi, I have a problem. We have web applications on 2 seperate servers that need to talk to each other. App 1 needs to pop open a second windos with App2 in it where you choose a value and that is...
0
by: Brett Mostert | last post by:
Hi, I need to be able to Enumerate through Printer Drivers, ports, printers and so fourth. And even add printers, ports, and drivers and setup printers. Sofar i can do all of the following...
1
by: Howard | last post by:
I have been trying to run pages that I design with the extension of .asp and they appear to run but never call the web browswer. If I take the same page and rename it using the aspx extension I can...
0
by: Chang Shiung | last post by:
Hi We have discovered a problem when printing web pages in Internet Explorer 6 (IE6) that have HTML sources like this <TABLE ....><TR><TD><TABLE .... that spans more than one page...
1
by: Alejandro Penate-Diaz | last post by:
Hi. I need to iterate through the Page controls collection in order tu enumerate every control on it. I though this was enough as I read from 4guysfromrolla: void Page_Load(Object sender,...
0
by: vlado.eltrade | last post by:
Hi there. I have a problem with wrong MS Access report Pages property after hiding the page footer section on the report. The pages propery reffers to the max number of pages as the section was...
3
Vini171285
by: Vini171285 | last post by:
Hi.. I have a form,it consists of a six list boxes and depending on selection of that boxes i have to display six pages .. i have used an array to store these values and case to go to particular...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.