0% found this document useful (0 votes)
26 views2 pages

My Mat For Web Application

The document discusses using a dropdown list change event in ASP.NET where setting the AutoPostBack property to true and handling the SelectedIndexChanged event allows updating another control on the page. Sample code is provided using this approach with a dropdown list and textbox. Additional suggestions are made to use JavaScript to allow only numeric input in a textbox.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
26 views2 pages

My Mat For Web Application

The document discusses using a dropdown list change event in ASP.NET where setting the AutoPostBack property to true and handling the SelectedIndexChanged event allows updating another control on the page. Sample code is provided using this approach with a dropdown list and textbox. Additional suggestions are made to use JavaScript to allow only numeric input in a textbox.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 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