Problem with Visual Studio 2005 migration

Posted on 2006-05-23
Last Modified: 2010-04-16
I have a page which used to work in Visual Studio 2003 but now it doesn't. The code that seems to have the problem is:

<table class="leftSideBoxC" cellspacing="0" cellpadding="0" width="100%" border="0">

      <%for (int i=0;i+1<=sub_categories.Count;i++)         { //Here starts the loop for types categories %>

      <%if (((ArrayList)((ArrayList)sub_categories[i])[0])[0].Equals(rootCategory)) {%>


            <td class="categories" align="left" valign="middle"><%=((ArrayList)((ArrayList)sub_categories[i])[0])[1]%></td>


      <%} else {%>


            <td class="categories" align="left" valign="middle"><a href="<%=Session["SiteUrl"].ToString()+"/"+FrameWork.Constants.getUrlFriendly(((ArrayList)((ArrayList)sub_categories[i])[0])[1])%>/category.aspx?id=<%=((ArrayList)((ArrayList)sub_categories[i])[0])[0]%>"><%=((ArrayList)((ArrayList)sub_categories[i])[0])[1]%></a></td>



      <%if (((ArrayList)((ArrayList)sub_categories[i])[0])[0].Equals(rootCategory)) {%>

      <%for (int k=1;k+1<=((ArrayList)sub_categories[i]).Count;k++)           { //Here starts the loop for types categories %>                


            <td class="sub_categories" align="left">

                  <a href="<%=Session["SiteUrl"].ToString()+"/"+FrameWork.Constants.getUrlFriendly(((ArrayList)((ArrayList)sub_categories[i])[0])[1])+"/"+FrameWork.Constants.getUrlFriendly(((ArrayList)((ArrayList)sub_categories[i])[k])[1])%>/category.aspx?id=<%=((ArrayList)((ArrayList)sub_categories[i])[k])[0]%>">









Moreover, the problem is that whenever the page loads it does not continue to Page_Load if I have this code. It's so strange...

Any ideas would be highly appreciated.

Question by:infodigger
    LVL 25

    Expert Comment

    Are you getting errors or does it just not behave as expected?

    Author Comment

    It's hard to say. Because with the file I am posting here I am getting an error which says that this line is incorrect:

    Line 36:       <%if (((ArrayList)((ArrayList)sub_categories[i])[0])[0].Equals(rootCategory)) {%>

    because rootcategory does not exist in current context. However, it exists but somehow the code is not loaded. The acsx page I am posting inherits another cs page and also have a codebehind property to another page.

    I had almost the same problem with another page and I fixed it by making AutoEventWireup="True" instead of False.

    Author Comment

    Just to add something to the previous example.

    This is the first line of the ascx page:

    <%@ Control Language="c#" AutoEventWireup="True" Codebehind="leftbarCategoriesB.ascx.cs" Inherits="FrameWork.components.leftbarCategories"  targetSchema=""%>

    When you add a breakpoint at the Page_Load seciton of the leftbarCategoriesB.ascx.cs file it does not get hit.

    LVL 25

    Accepted Solution

    It seems like the Page_Load is not being wired up automatically.  That is what AutoEventWireup="True" does.  If it's not wired up, any varaibles declared in Page_Load will not be available in your inline script.

    You can try AutoEventWireup="False" and wiring up any events manually in the constructor:

    this.Load += new System.EventHandler(this.Page_Load);

    BTW, this is the default for VS 2003. I believe that VS2002 used AutoEventWireup="True" by default.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
    This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video discusses moving either the default database or any database to a new volume.

    737 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now