Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 2

Cor Ligthert November 21st, 2005 • Subscribe to Threa

Guest 03:40 AM • Post Your Questio


n/a Posts #5

Re: drop down list change event


Rodchar,

Real live or in your test situation, in the last situation the answer is no,
there was another question about this that I answered today and I forget
that I had planned to do this to you to when I tested that, I did not see
it.

The screen was as flat as flat could be with this code (I filled the
collection with 6 items and no values)
\\\
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load sponsor content
If Not IsPostBack Then
Me.DropDownList1.AutoPostBack = True
End If
End Sub
Private Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles DropDownList1.SelectedIndexChanged
TextBox1.Text = DropDownList1.SelectedItem.ToString
End Sub
///
Maybe this helps still something

Cor
Or I you want to use Java Script then onKeyPress event of the text box you can call a

Javascript function that would allow only numeric input to be entered.

Sample Code:

<HTML>
<HEAD>
<SCRIPT language=Javascript>
<!--
function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

return true;
}
//-->
</SCRIPT>
</HEAD>
<BODY>
<asp:TextBox ID="TextBox1" runat="server" onKeypress="return
isNumberKey(event)" />
</BODY>
</HTML>
This code wont allow alphabets

protected void Page_Load(object sender, EventArgs e)


{
TextBox1.Attributes.Add("onKeypress", "return isNumberKey(event);");
}

http://msdn2.microsoft.com/en-us/library/aa479568.aspx

You might also like