[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

unordered list help

Posted on 2006-06-18
3
Medium Priority
?
883 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 2000 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

Industry Leaders: 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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
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…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

825 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