Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

<%@ 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?

Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Posted

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.

Posted
how did i fire it, and lose focus? coz i dun see any part where i lose focus...
Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Posted
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?
Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...
Posted

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

Posted
i see...client side........er....asp.net is just for server side is it?
Can you bind the beautiful Pleiades, and can you loose the cords of Orion? - God to Job...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...