need your help please,
please have look at the script
------------------
<%@dotnet.itags.org. Page Language="VB" %>
<script runat="server"
' Insert page code here
'
Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)
label1.text=dropdownlist1.selecteditem.text
End Sub
</script>
<html>
<head>
</head>
<body>
<form runat="server">
<p>
<asp:DropDownList id="DropDownList1" runat="server" ForeColor="Red" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem Value="1991">1991</asp:ListItem>
<asp:ListItem Value="1992">1992</asp:ListItem>
<asp:ListItem Value="1993">1993</asp:ListItem>
</asp:DropDownList>
</p>
<p>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</p>
<!-- Insert content here -->
</form>
</body>
</html
------------------
what I want to achive is that when I select a value form the drop done list it automaticaly print the value in the label ( with out submiting or pressing any button)
many thanks indeed
MUse
<asp:DropDownList id="DropDownList1" runat="server" ForeColor="Red" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" AutoPostBack="True">
This will postback the form and fill your label.
Simon
I am not particularly fond of including the VB code in Script tags on the ASPX page, here's what I recommend:
ASPX PAGE
<%@. Page Language="vb" AutoEventWireup="false" Codebehind="WebForm1.aspx.vb" Inherits="YourRoot.WebForm1"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" content="Visual Basic .NET 7.1">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<asp:DropDownList id="DropDownList1" runat="server"AutoPostBack="True">
<asp:ListItem Value="1991">1991</asp:ListItem>
<asp:ListItem Value="1992">1992</asp:ListItem>
<asp:ListItem Value="1993">1993</asp:ListItem>
</asp:DropDownList>
<asp:Label id="Label1" runat="server">Label</asp:Label>
</form>
</body>
</HTML>
CODEBEHIND
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
Label1.Text = DropDownList1.SelectedItem.Text
End Sub
Good Luck
I agree
Simon
thanks alot, it did work
0 comments:
Post a Comment