fkheng Posted September 16, 2003 Posted September 16, 2003 <%@ Page Language="VB"%> <script runat="server"> Sub tbMessage_Change(Sender as Object, E as EventArgs) lblMessage.text = "Hello " + tbMessage.text End Sub </script> <HTML> <body> <font size="5">Sam's Teach Yourself ASP.NET in 21 Days: Day 2 </font> <hr> <p> <% Response.Write("Our First Page<p>") %> <form runat="server"> Please enter your name: <asp:TextBox ID="tbMessage" OnTextChanged="tbMessage_Change" runat=server /> <asp:Button ID="btSubmit" Text="Submit" runat=server /><p> <asp:Label ID="lblMessage" Font-Size="20pt" runat=server /> </form> </p> </body> </HTML> I have obtained this piece of code from some book, and would like to ask some questions. During run-time, based on my understanding, please correct me if I am wrong, as I type text into the textbox, the TextChanged Event is fired. Based on the above code, as the letters are typed consecutively into the textbox, the letters should also be consecutively reflected in the lblMessage label. But somehow, the label only displays the message after I press the Submit button. Furthermore, I do not see any code here which links the submit button to the tbMessage_change procedure. Could someone please clarify the situation to me? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
bungpeng Posted September 16, 2003 Posted September 16, 2003 1. "onChange" fired when you change something in textbox and 'lost focus'. 2. To show result without pressing the Submit button, you need to set the "auto-postback" properties for textbox = 'true' (as above) P/S: you need to understand the Internet architecture, "PostBack/Submit" mean you send request to server for another page, so we should try to avoid it if possible. Quote
fkheng Posted September 16, 2003 Author Posted September 16, 2003 how did i fire it, and lose focus? coz i dun see any part where i lose focus... Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
fkheng Posted September 16, 2003 Author Posted September 16, 2003 sorry, i just tried, and understand wat u mean, but the result is only displayed only if i press submit button or shift the focus elsewhere...is there really no way of displaying the result for each letter typed for example? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
bungpeng Posted September 17, 2003 Posted September 17, 2003 I think you able to do it using Javascript in key press event, but I don't think it is practical because when user press 1 key, you need to submit once.... I think you should do it in client site if possible rather than every time go back to server Quote
fkheng Posted September 17, 2003 Author Posted September 17, 2003 i see...client side........er....asp.net is just for server side is it? Quote Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.