Printer Friendly Version Print this thread
Email this thread to a friend eMail this thread to a friend
Featured Web Site Template

Hundreds More at Free Site Templates.com!

Web Site Partners
Sponsored Links
Jet City Software
 
Whos Here ?
Reflects user activity within the last 5 minutes
Moderator(s): Prowler, jcokos
Member Message

butbut
Joined: Jan 10, 2005
# Posts: 19

View the profile for butbut Send butbut a private message

Posted: 2005-Apr-18 13:38
Edit Message Delete Message Reply to this message

Hello there...

Can someone tell me how I can create the following effect using javascript on a asp.net textbox:
The textbox say 'type here...' and i want that text cleared when onFocus.
The effect work on a normal html texbox but not on my asp.net textbox.

i'm using the following function that's caled by the onFocus:
(in stead of using the name tag i use getElementById here)

function getEmpty (){
document.form01.getElementById("txt_Search"wink.value='empty';
}

Thanx in advance

Koen



ask_hassan
Joined: Aug 21, 2008
# Posts: 1

View the profile for ask_hassan Send ask_hassan a private message

Posted: 2008-Aug-21 08:28
Edit Message Delete Message Reply to this message

hi there,
It seems you want the code for the asp.net textbox control to clear the default value.Here is the easiest way.Try this

In aspx.cs,

write this in the page_load

txtUserName.Attributes["value"] = "User Name";
txtPassword.Attributes["value"] = "Password";
txtUserName.Attributes.Add("onFocus", "this.value=''"wink;
txtPassword.Attributes.Add("onFocus", "this.value=''"wink;

If you face any more trouble with this code.Please let me know.I will clear your doubt.
Regards
-Hassan





chyde
Joined: Sep 09, 2008
# Posts: 1

View the profile for chyde Send chyde a private message

Posted: 2008-Sep-10 00:15
Edit Message Delete Message Reply to this message

Good code, do you know how do you do this in VB? I got an error.

In page load in code behind:

fvOnfocusDelete("tbAcceptDate"wink

Private Sub fvOnfocusDelete(ByVal fvTbName As String)

Dim tbInitial As TextBox = CType(fvInitial.FindControl(fvTbName), TextBox)
tbInitial.Attributes.Add("onFocus", "this.value =''"wink

End Sub

Error = Message="Object reference not set to an instance of an object."








You are not permitted to post messages in this forum or topic, because of one or more of the following reasons:
  1. You have not yet logged in, or registered properly as a member
  2. You are a member, but no longer have posting rights.
  3. This is a private forum, for which you do not have permissions.

If you are a recent member, it's possible that you simply have not yet confirmed your account. Please check your email for a message entitled 'JimWorld Forums: Confirm Your Account' and follow the instructions contained within.

If you cannot find this message, click here to Re-Send it.

If you are still experiencing problem, please read the Login Assistance Article for some advice on what may be causing your login not to work properly.

Switch to Advanced Editor and ... Create a New Topic or Reply to this Thread

New posts Forum is locked
© 1995  ·  iWeb, Inc  ·  DBA JimWorld Productions