Nov 22, 2004 #1 boatdrinks IS-IT--Management Jun 18, 2004 51 US if I have an asp.net textbox called textbox2 how do I get the text "DTP" to appear in the textbox when the cursor enters it?
if I have an asp.net textbox called textbox2 how do I get the text "DTP" to appear in the textbox when the cursor enters it?
Nov 22, 2004 1 #2 cLFlaVA Programmer Jun 14, 2004 6,450 US One way: Code: <input type="text" name="textbox2" onfocus="if (this.value == '') {this.value = "DTP";}" /> *cLFlaVA ---------------------------- "Holy crip he's a crapple! Upvote 0 Downvote
One way: Code: <input type="text" name="textbox2" onfocus="if (this.value == '') {this.value = "DTP";}" /> *cLFlaVA ---------------------------- "Holy crip he's a crapple!
Nov 22, 2004 Thread starter #3 boatdrinks IS-IT--Management Jun 18, 2004 51 US <asp:textbox id="textbox2" runat="server" /> This gives errors when I past the onfucus..... into it Upvote 0 Downvote
Nov 22, 2004 #4 cLFlaVA Programmer Jun 14, 2004 6,450 US Well, I messed up the quotation marks. Other than that, I'm not very familiar with that form of coding. For future reference, my code should have been: Code: <input type="text" name="textbox2" onfocus="if (this.value == '') {this.value = [red]'[/red]DTP[red]'[/red];}" /> *cLFlaVA ---------------------------- "Holy crip he's a crapple! Upvote 0 Downvote
Well, I messed up the quotation marks. Other than that, I'm not very familiar with that form of coding. For future reference, my code should have been: Code: <input type="text" name="textbox2" onfocus="if (this.value == '') {this.value = [red]'[/red]DTP[red]'[/red];}" /> *cLFlaVA ---------------------------- "Holy crip he's a crapple!
Nov 22, 2004 Thread starter #5 boatdrinks IS-IT--Management Jun 18, 2004 51 US Thanks that did it. Upvote 0 Downvote
Nov 22, 2004 #6 tgreer Programmer Oct 4, 2002 1,781 US You can use: textbox2.Attributes.Add("onfocus",@"if (this.value == '') {this.value = 'DTP';}"; in your code-behind. Thomas D. Greer http://www.tgreer.com Providing PostScript & PDF Training, Development & Consulting Upvote 0 Downvote
You can use: textbox2.Attributes.Add("onfocus",@"if (this.value == '') {this.value = 'DTP';}"; in your code-behind. Thomas D. Greer http://www.tgreer.com Providing PostScript & PDF Training, Development & Consulting