Solved

unordered list help

Posted on 2006-06-18
3
875 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-
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How come this regular expression allows "e"? 14 56
insert value of checklistbox checked 4 38
Dictionary and array of [N] size - performance tuned 12 40
Problem to copy file 14 44
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
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 …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

713 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