Solved

unordered list help

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

746 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

9 Experts available now in Live!

Get 1:1 Help Now