how to Show ToolTip in Key Press of a textbox

Posted by Santosh4u under VB.NET on 5/3/2010 | Views : 11113 | Status : [Member] | Replies : 2
Hi
Can any body plz tell me
how to set ToolTip in KeyPress of a Textbox.

Ex:Let a Textbox is txtSalary ,when i will type anything in that textbox it should show a tooltip like("Salary should ne Decimal Only")

which event i need to write the code to show the toltip

Regards
Santosh




Responses

Posted by: Nishithraj on: 5/3/2010 [Member] Bronze

Up
0
Down
That's very easy you can do that with a javascript function as follows

<script type="text/javascript">

function tooltip()
{document.getElementById('text1').title="Salary should ne Decimal Only";}
</script>
<form>
<input type="text" id="text1" size=25 onclick="tooltip();" >
</form>


In case if you are using an asp text box, add the function tooltip as a attribute.

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Er.deepakdalal on: 5/3/2010 [Member] Starter

Up
0
Down
Hi Santosh4u

You can set your tooltip on the textbox keypress event or on the textbox focus or textbox key down event. Take hint from the below code:-

Private Sub textDate_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles textDate.KeyPress

If (Microsoft.VisualBasic.Asc(e.KeyChar) < 65) Then
ToolTip1.SetToolTip(TextBox1, "Salary should be Decimal Only.")
End If
End Sub

Santosh4u, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response