473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

can I use WithEvents in standalone aspx?

Hello,

I have been experimenting/learning to use aspx with and
without VS2003. In VS 2003 I created a simple
webform/application which contains a listbox and a label.
I populate the listbox and on the

"OnSelectedIndexChanged="lstProducts_SelectedIndex Changed"

event of the listbox (called in the html section) I write
the value/index in the label for the selected item.

In the VS 2003 app I don't need to add

"OnSelectedIndexChanged="lstProducts_SelectedIndex Changed"

to the <asp:listbox... tag in the html section because the
code region has WithEvents declarations.

But in a standalone aspx I have to add the event call

"OnSelectedIndexChanged="lstProducts_SelectedIndex Changed"

to the listbox tag in the html section to get the click
event. I tried Dim WithEvents ListBox1... in the script
section of the aspx (and removed the event call in the
<asp:listobx tag of the html section) but got an error
message that ListBox1 was already declared -- except the
declaration did not include WithEvents and I did not have
a click event without the event call in the
<asp:listbox...tag. So if it is possible to use
WithEvents in a Standalone aspx, how would I declare
ListBox1 WithEvents? Here is what I have already tried:

<%@ Import Namespace="System.IO" %>
<script language="VB" runat="server">
Dim WithEvents ListBox1 As
System.Web.UI.WebControls.ListBox
Sub Page_Load(Src as Object, E as EventArgs)
If Not IsPostBack Then
.... populate ListBox1
End Sub

Sub ListBox1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Label1.Text = "You selected " &
ListBox1.SelectedItem.Text
End Sub

Thanks,
Steve

Nov 18 '05 #1
0 1224

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jonas | last post by:
This works fine in Win XP but does not work at all in Win 98. Private WithEvents objIExplorer As InternetExplorer I have to do it like this to get it to work in Win 98 Dim objIExplorer As...
5
by: Bradley Grant | last post by:
I am trying to write a program to access a device through USB port, there is some Visual Basic program examples that work with the device, but I am trying to write a program using C#, no luck yet,...
1
by: Martin Raychev | last post by:
Hi everyone, I have to design an application which has to display some graphics of maritime data. I am wondering whether it could be web application (ASP.NET) or standalone C# application.
4
by: Brian Lowe | last post by:
I have several aspx pages that include a couple of asp:placeholder controls, an example is myPage.aspx. The page inherits from a custom class 'myClass' which inherits System.Web.UI.Page which...
4
by: Shapper | last post by:
Hello, I have an aspx.vb page with this code: Public Class WebForm1 Inherits System.Web.UI.Page Protected WithEvents Menu1 As MenuControl.Web.UI.Menu ... If I have my code in the aspx...
0
by: hansiman | last post by:
I sometimes see references to controls that has been removed from the aspx page in the code behind. The references linger in the region "Web Form Designer Generated Code" and look like Protected...
8
by: Bob Day | last post by:
Using VS 2003, VB.NET, MSDE If an event is raised in a class that was NOT instantiated with the WithEvents key word, is that event effectively ignored? Or, another way to phrase the question,...
7
by: tah | last post by:
Hey, Can someone please clarify, confirm, or set me straight on my understanding of a standalone="yes" attribute in the xml version element? I assume it means that the xml document containing it...
4
by: =?Utf-8?B?R3V5IENvaGVu?= | last post by:
Hi all I googled some and found that I can no longer - dim withevents myclassname() I also understand that I can use addhandler... But... what if I do not know the amount of classes that will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.