Here's the 30,000-ft. view: I wrapped an asp:Menu control in an ascx control. When I try to dynamically populate the menu in the ascx control, the items appear, but clicking on them fails to trigger the MenuItemClick event handler. However, if I statically declare the menu items in the .ascx page, everything is fine. Any ideas?
Here's the details:
My ascx page: -
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="TabStrip.ascx.vb" Inherits="TabStrip" %>
-
<asp:Menu runat='server' ID='muStrip' orientation='horizontal'>
-
</asp:Menu>
-
Code in my ascx.vb file: -
...
-
Public Sub AddItem(ByVal sText As String, ByVal bSelected As Boolean)
-
If (bSelected) Then
-
For i As Integer = 0 To muStrip.Items.Count - 1
-
muStrip.Items(i).Selected = False
-
Next
-
End If
-
Dim mui As New MenuItem(sText)
-
mui.Selectable = True
-
mui.Selected = bSelected
-
muStrip.Items.Add(mui)
-
End Sub
-
-
Protected Sub muStrip_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles muStrip.MenuItemClick
-
' Raise user event handler.
-
RaiseEvent ItemClick(sender, e, miSelectedItem)
-
End Sub
-
...
-
Code in my calling-page .vb file: -
...
-
Protected Overrides Sub HandlePageLoad()
-
MyBase.HandlePageLoad()
-
-
' Populate the tab strip.
-
If Not Page.IsPostBack Then
-
oxiTab.AddItem(" Administrative", True)
-
oxiTab.AddItem(" Maintenance", False)
-
oxiTab.AddItem(" Tests/Requests", False)
-
oxiTab.AddItem(" Reports", False)
-
End If
-
End Sub
-
...
-
If I put a breakpoint at the "RaiseEvent " call and try clicking on any menu item, I never reach the breakpoint. But if I add static menu items in the ascx page, the breakpoint IS reached.
Thanks.
1 7160 Click Event for dynamically added toolstripmenu items
SqlCommand cmd = new SqlCommand("sel ect mytablename from ds_table", con);
SqlDataAdapter da= new SqlDataAdapter( cmd);
con.Open();
DataSet ds = new DataSet();
da.Fill(ds);
SqlDataReader dr = cmd.ExecuteRead er();
MenuStrip menu = new MenuStrip();
ToolStripMenuIt em item = new ToolStripMenuIt em("Reports");
while (dr.Read())
{
ToolStripMenuIt em inneritem = new ToolStripMenuIt em(dr["mytablenam e"].ToString());
item.DropDownIt ems.Add(innerit em);
menu.Items.Add( item);
this.Controls.A dd(menu);
inneritem.Click += new EventHandler(in neritem_Click);
}
con.Close();
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Nathan Bloomfield |
last post by:
Does anyone know if there is any documentation which relates to Access2k + ?
or can anyone help adjust the code?
I am having trouble converting the DAO references.
TITLE :INF: How to Create a Dynamic Crosstab Report
PRODUCT :Microsoft Access
PROD/VER:1.00 1.10
OPER/SYS:WINDOWS
|
by: tmaster |
last post by:
When I try to dynamically add a second sub menu item to this ContextMenu
item, I get an error 'Specified argument was out of the range of valid
values'.
Private Sub mnuTopics_Show_Select(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles mnuTopics_Show.Select
Dim mShowMenuItem As MenuItem
mShowMenuItem = DirectCast(sender, MenuItem)
|
by: Chris Murphy via DotNetMonster.com |
last post by:
Hi all, I'm just wondering if any one can help me with this development
issue I'm having. I've created a customized treeview control to handle the
particular tasks to which I'll be using it. Within the control I'm
dynamically creating a context menu and assigning it to the ContextMenu
property of the control -- think of this like the default context menu for
standard textboxes -- the context menu has a number of menu items that
reflect...
|
by: Ron M. Newman |
last post by:
Hi,
Just need a little advice. Id like to build *dynamic* context menus for tree
nodes. I'm pretty versed in building context menus and attaching them to
tree nodes.
My question is, what event to I "capture" in order to build the tree node
menu in real time? right click on a tree node? or is it too late?
just FYI: the menu is different for each node and is based on "real time"
|
by: =?Utf-8?B?ZWFndWlsYXI=?= |
last post by:
Hi,
I am trying to dynamically generate a menu, based on entries on a text or
xml file. The text file contains the "tree" after which the menu will need to
be created. Something like the following:
Level 1
-- Level 2
-- Level 2
Level 1
| |
by: Karl Rhodes |
last post by:
I'm building a windows forms app in VB.net 2005 and would like to know
if there is any way of adding a handler using a dynamic AddressOf
value?
The application will have a "Windows" menu item and I want to add a
list open forms as other menu items to this list. I want to be able to
do this dynamically and create a handler for each one that I add.
However, instead of creating the handler everytime i open a new form,
I want to use a...
|
by: PetterL |
last post by:
I writing a program where I read menu items from a file. But I have problem
when I click an menu item i want it to mark that one as checked but I cant
access the menu object of that item to see witch object was selected.
This is the sub procedure that read the items from an Array and create the
menutitem. The array hold more information to use in program when one of the
items is selected.
Dim finisharray(,) As String ' is set up...
|
by: JamesOo |
last post by:
I have the code below, but I need to make it searchable in query table,
below code only allowed seach the table which in show mdb only. (i.e. have 3 table, but only can search either one only, cannot serch by combine 3 table)
Example I have the query table below, how do I make the code to seach based on the query from this:
SELECT Product.ID, Product.Description, Quantity.Quantity, Quantity.SeialNo, Quantity.SupplierID,...
|
by: libish |
last post by:
hi all...
can any one help me by suggesting a way to get items in dynamic form?
here what i'm doing is , i'm displaying a dynamic form. in that form i have a main menu and this main menu contains a menu item "OK". here the dynamic form consist of some labels, list items and all. when i click on the "OK" menu item, an event occurs and i've wrote methods which wll execute on this event.
now i need the selected list item index,value.. label...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |