?
Solved

Receiving error when using an ssi include in asp.net vb

Posted on 2009-07-12
4
Medium Priority
?
262 Views
Last Modified: 2013-11-26
I have a web page programmed in asp.net vb.  I am using a server side include for a top menu.  The page I'm including is aa_includes/menu_top1.txt.  In Visual Studio 2008, when I flip to "Design" mode to see the page, I get an error "Error Creating Control - Table1, Object reference not set to an instance of an object."  I have pin pointed the problem to the actual include statement.  If I take the include out, the error goes away and I can use the "Design" mode in Visual Studio 2008.  I can't seem to figure out how to resolve this problem.  I have attached the code for the web page and attached the include file.  Thanks for any guidance.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css"></style>
    <link href="main_site.css" rel="stylesheet" type="text/css" />    
 
</head>
<body>
    <asp:Table ID="Table1"  Width="100%" Height="100%" BackColor="White" runat="server">
        <asp:TableRow>
            <asp:TableCell  HorizontalAlign="Center" VerticalAlign="Top">
                <asp:Table ID="Table2" runat="server">
                    <asp:TableRow CssClass="TopRow1">
                        <asp:TableCell>
                            <asp:Table ID="Table3" width="800" HorizontalAlign="Center" runat="server">
                                <asp:TableRow HorizontalAlign="Right">
                                    <asp:TableCell>
                                    <!-- #Include file="aa_includes/menu_top1.txt" -->
                                    </asp:TableCell>                                
                                </asp:TableRow>                                                                                    
                            </asp:Table>                                                                                                                        
                        </asp:TableCell>                    
                    </asp:TableRow>                                                                                                    
                </asp:Table>                        
            </asp:TableCell>                
        </asp:TableRow>            
    </asp:Table>
</body>
</html>

Open in new window

menu-top1.txt
0
Comment
Question by:OB1Canobie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 15

Accepted Solution

by:
jinal earned 2000 total points
ID: 24835022
Hello ,

Try to use UserControl .



/* WebUserControl3.ascx */
<%@ Control Language="VB" AutoEventWireup="true" CodeFile="WebUserControl3.ascx.vb" Inherits="WebUserControl3" %>
<asp:table ID="TopRowMenu" HorizontalAlign="Right" runat="server">
    <asp:TableRow HorizontalAlign="Right">
        <asp:TableCell CssClass="TopRowMenu"><a onmouseover="CssClass='TopRowMenu'" onmouseout="CssClass='TopRowMenu'" onclick="location.href='aa_aboutus/servicetimes.aspx'">Service Times</a></asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu">&nbsp;|&nbsp;</asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu"><a onmouseover="CssClass='TopRowMenu'" onmouseout="CssClass='TopRowMenu'" onclick="location.href='aa_aboutus/directions.aspx'">Direction</a></asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu">&nbsp;|&nbsp;</asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu"><a onmouseover="CssClass='TopRowMenu'" onmouseout="CssClass='TopRowMenu'" onclick="location.href='aa_secure/announcements.aspx'">Announcements</a></asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu">&nbsp;|&nbsp;</asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu"><a onmouseover="CssClass='TopRowMenu'" onmouseout="CssClass='TopRowMenu'" onclick="location.href='aa_aboutus/contactus.aspx'">Contact Us</a></asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu">&nbsp;|&nbsp;</asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu"><a onmouseover="CssClass='TopRowMenu'" onmouseout="CssClass='TopRowMenu'" onclick="location.href='quicklinks.aspx'">Quick Links</a></asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu">&nbsp;|&nbsp;</asp:TableCell>
        <asp:TableCell CssClass="TopRowMenu"><a onmouseover="CssClass='TopRowMenu'" onmouseout="CssClass='TopRowMenu'" onclick="location.href='aa_webcasts/podcasts.aspx'">Podcasts</a></asp:TableCell>
    </asp:TableRow>                            
</asp:table>
 
/* ASPX */
 
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<%@ Register src="WebUserControl3.ascx" tagname="WebUserControl3" tagprefix="uc1" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <style type="text/css"></style>
    <link href="main_site.css" rel="stylesheet" type="text/css" />    
 
</head>
<body>
    <asp:Table ID="Table1"  Width="100%" Height="100%" BackColor="White" runat="server">
        <asp:TableRow>
            <asp:TableCell  HorizontalAlign="Center" VerticalAlign="Top">
                <asp:Table ID="Table2" runat="server">
                    <asp:TableRow CssClass="TopRow1">
                        <asp:TableCell>
                            <asp:Table ID="Table3" width="800" HorizontalAlign="Center" runat="server">
                                <asp:TableRow HorizontalAlign="Right">
                                    <asp:TableCell>
                                   <uc1:WebUserControl3 ID="WebUserControl31" runat="server" />                                    </asp:TableCell>                                
                                </asp:TableRow>                                                                                    
                            </asp:Table>                                                                                                                        
                        </asp:TableCell>                    
                    </asp:TableRow>                                                                                                    
                </asp:Table>                        
            </asp:TableCell>                
        </asp:TableRow>            
    </asp:Table>
</body>
</html>

Open in new window

0
 

Author Comment

by:OB1Canobie
ID: 24835030
jinal:

I understand what you suggested, but what I am trying to accomplish is have one menu file as an include where I can edit in one place and all web pages are effected.  If I use the webcontrol method, if I make a change in the menu, I would have to change all pages in the site, and currently there are over 100.  Any other ideas of how accomplish what I am attempting?
0
 
LVL 15

Expert Comment

by:jinal
ID: 24835039
Hello ,

I am not understanding what you are saying ?
If you create one user control . then you put that control on 100 pages. Now you made changes to UserControl than it automatically reflect in all pages.
0
 

Author Closing Comment

by:OB1Canobie
ID: 31602596
jinal: Thanks for your help.  The code worked great.
0

Featured Post

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shoutout to Emily Plummer (http://www.experts-exchange.com/members/eplummer26.html) for giving me this article! She did most of it, I just finished it up and posted it for her :)    Introduction In a previous article (http://www.experts-exchang…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

752 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