Solved

unordered list help

Posted on 2006-06-18
3
877 Views
Last Modified: 2008-02-26
I've created an user control that contains a unordered list:

<%@ Control Language="vb" AutoEventWireup="false" Codebehind="TopMenuBar.ascx.vb" Inherits="compasslearning.TopMenuBar" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<table border="0" cellpadding="0" cellspacing="0">
<colgroup align=left width=50% span=1></colgroup>
<colgroup align=right width=50% span=1></colgroup>
<tr>
<td>
<ul>
<asp:Repeater ID="topmenu" Runat="server">
<ItemTemplate>
<li>
<!--<%# DataBinder.Eval(Container.DataItem, "Item") %>-->
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
</td>
<td>
<form name=frmSearch method=POST action="search.asp" style="margin:0px">Search
<input type="text" size="25" name="txtQuery">
<a href="javascript:document.frmSearch.submit()"><img src="images/go.gif" align="absmiddle" border="0"></a>
</form>
</td>
</tr>
</table>

I'm trying to control the visibility of the list in the code-behind

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here

        Dim MenuItems As New ArrayList

        MenuItems.Add("About Us")
        MenuItems.Add("Contact Us")
        MenuItems.Add("Customer Support")
        MenuItems.Add("Site Map")

        Dim topmenu
        topmenu.Visible = False
    End Sub


I'm getting the following error: Object variable or With block variable not set.
which occurs on the following line: topmenu.Visible = False

I'm going to eventually wrap this in an If statement and turn off the visibility based on a recordset value.


Thanks,
-D-
0
Comment
Question by:-Dman100-
[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
3 Comments
 
LVL 7

Expert Comment

by:kGenius
ID: 16932798
Dim topmenu As New TopMenuBar

hope this 'll help
kGenius
0
 
LVL 20

Accepted Solution

by:
REA_ANDREW earned 500 total points
ID: 16932851
My Advice to you would be, to steer away from using HTML controls to achieve this, as ASP.NET provides you with all the functionality you need. Here is an example of how I create this in ASP.NET C# Code Behind

        BulletedList MyList = new BulletedList();
        MyList.BulletStyle = BulletStyle.Numbered;
        ListItem MyItem = new ListItem();
        MyItem.Text = "BulletNumbered";
        MyList.Items.Add(MyItem);
        form1.Controls.Add(MyList);
0
 

Author Comment

by:-Dman100-
ID: 16935845
I'm just kind of getting my feet wet with .net.

I was following your code example and think I have a basic understanding your example.

You're defining a new bulleted list
Defining the style of the bulleted list
Defining a new listItem
Creating what each list item would be --- how do you add more than one list item, just add new items seperated by semi-colons?
Add the items to the bulleted list "MyList"
Finally add the control name that can be referenced in the user control.

Am I understanding this correctly?

So, if I want to access that new control, I'd simply use:

<asp:MyList Runat="Server"></asp:MyList>

I hope I understand this correctly.

What are the benefits to handling the development of the list this way rather than the method I was trying?  Is there an example I can find using VB.NET?

Thanks for your help.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

696 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