Click here to Skip to main content
15,903,385 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Plz...Can anyone help me in code,how to apply 'onblur' on textbox in asp.net(MS visual web developer 2010 express)
Thank You....
Posted
Updated 2-Jul-11 2:08am
v3

You can do it in both design file or in code behind file

Design:
<asp:TextBox runat="server" onblur="Javascript:alert('1234');" />


Code Behind:

myTextBox.Attributes.Add("onblur","alert('1234');");
 
Share this answer
 
I found this with google (google is free - you can use it too).

In your aspx file:

<asp:textbox onblur="javascript:msgBox('test');"/> // assume msgBox is your own javascript function


In your aspx.cs file:

C#
protected void Page_Load(Object sender, System.EventArgs a)
{
    TextBox1.Attributes.Add("onblur", "javascript:msgbox('Test');");
}
 
Share this answer
 
Comments
M.imran ali 2-Jul-11 8:33am    
Thanks John...I tried that too...but iam getting compilation error
[no name] 2-Jul-11 9:10am    
It is customary to post the error you are getting, not just saying you are getting one. Add it to the question.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900