ac_davis2002
asked on
Visual studio on click
Hi
I am just starting to use visual studio, can anyone give me an example of code that returns values to a list box on the click of a button. I'm not bothered what the values are just won't to see how its done?
Thanks
I am just starting to use visual studio, can anyone give me an example of code that returns values to a list box on the click of a button. I'm not bothered what the values are just won't to see how its done?
Thanks
ASKER
I will take a look, i am trying to use vB2005 do you have any examples using that?
VB2005 with ASP.NET or desktop applications ?
with asp.net/VB.Net you can do something like this
ASPX FILE
=====================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="ListBox_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox runat="server" ID="lstbxTest">
</asp:ListBox>
<asp:TextBox runat="server" ID="txtTest"></asp:TextBox >
<asp:Button runat="server" ID="btnAdd" Text="Add" />
</div>
</form>
</body>
</html>
==============CODE BEHIND==================== ===
Partial Class ListBox_Default
Inherits System.Web.UI.Page
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
lstbxTest.Items.Add(New ListItem(txtTest.Text, txtTest.Text))
End Sub
End Class
ASPX FILE
=====================
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ListBox runat="server" ID="lstbxTest">
</asp:ListBox>
<asp:TextBox runat="server" ID="txtTest"></asp:TextBox
<asp:Button runat="server" ID="btnAdd" Text="Add" />
</div>
</form>
</body>
</html>
==============CODE BEHIND====================
Partial Class ListBox_Default
Inherits System.Web.UI.Page
Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
lstbxTest.Items.Add(New ListItem(txtTest.Text, txtTest.Text))
End Sub
End Class
ASKER
sorry I'm using windows applications
I really just want to see a command to populate a list box with values, do I need to use asp to do this?
I really just want to see a command to populate a list box with values, do I need to use asp to do this?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
cool thanks!!
http://www.codetoad.com/asp.net/aspnetcontrols9.asp