?
Solved

unordered list help

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

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

771 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