C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Forums » .NET » .NET »

OnFocus


Posted Date: 10 Oct 2008      Posted By: JK Chowdary      Member Level: Bronze     Points: 1   Responses: 4



How can i use onfocus in the text box




Responses

Author: Abhi    10 Oct 2008Member Level: BronzeRating: 2 out of 52 out of 5     Points: 5

<html>
<head>
<title>(Type a title for your page here)</title>
<script type="text/javascript">
function entername()
{
document.f1.t1.value="Name";
}
</script>

</head>
<body >

<form name=f1 action='' method=post>
Your Userid<input type=text name=t3><br>
Your Password<input type=text name=t2><br>
Your Name<input type=text name=t1 onfocus='entername()';>
</form>

</body>
</html>



Author: senthil    10 Oct 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 3

Focus method can run in the code behind.

u can create the button id=txt_Name

and code behind u write following code:

txt_Name.Focus();

Hope this is help for u....



Author: anil    10 Oct 2008Member Level: GoldRating: 2 out of 52 out of 5     Points: 5

u can do it using javascript as follows.

<html>
<head>
<script type="text/javascript">
function setStyle(x)
{
document.getElementById(x).style.background="yellow";
}
</script>
</head>
<body>
First name: <input type="text"
onfocus="setStyle(this.id)" id="fname">
<br />
Last name: <input type="text"
onfocus="setStyle(this.id)" id="lname">
</body>
</html>

this change the background color of textbox to yellow on focus.

thank you,
anil...

Thanks,
Anil.

http://akbbhatt.wordpress.com/
http://anilbhatt.blogspot.com/

If my reply helped you, then please rate this as Excellent, Good or Bad.



Author: Abhi    10 Oct 2008Member Level: DiamondRating: 2 out of 52 out of 5     Points: 5

you can set focus to text box or make change property of textbox on focus.

example:
<script language="javascript" type="text/javascript">
function setFocus()
{
document.getElementById('<%=txtendDate.ClientID%>').focus();
}

</script>

<body unload="setFocus()">

or

script language="javascript" type="text/javascript">
function setFocus(id)
{
document.getElementById(id).style.background="Red";
}

</script>


<input type="textArea"
onfocus="set(this)" id="comment">

Thanks and Regards,
Abhay



Post Reply

 This thread is locked for new responses. Please post your comments and questions as a separate thread.
If required, refer to the URL of this page in your new post.


Next : Abstract class and create(d) an instance in one application
Previous : Display the value in letters
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use