Click here to Skip to main content
15,867,453 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want to show the default value in the textbox1 in lite color before entering any value into the same text box

//example
when we are using any social networking sites means we will face this type of one while entering any name in the textbox..before only we will see name in lite color...when the courser goes into that textbox..automatically it will disappear
Posted

You should look into Ajax Control Toolkit's TextBox Watermark .

For more info:
http://www.asp.net/ajaxLibrary/AjaxControlToolkitSampleSite/TextBoxWatermark/TextBoxWatermark.aspx[^]

Good luck,
OI
 
Share this answer
 
Comments
fjdiewornncalwe 25-Feb-13 9:17am    
My 5.
Orcun Iyigun 25-Feb-13 10:16am    
Thank you Marcus.
Use Placeholder attribute inside the textbox.

example-
<asp:TextBox ID="txtName" PlaceHolder="Enter Your Name" runat="server"></asp:TextBox>


it works.
 
Share this answer
 
v2
Comments
ntitish 26-Feb-13 2:59am    
i am using visual studio 2008 it is not working sir..
Nandakishore G N 26-Feb-13 3:36am    
how did you add...paste it
ntitish 26-Feb-13 4:32am    
first i pasted sir after words i tried by typing but it is not coming
Nandakishore G N 26-Feb-13 6:13am    
which is the browser you are using?
ntitish 26-Feb-13 7:06am    
internet explorer while testing through local host
Follow this code you'll achieve your goal.

JavaScript
function onFocus() {
            var txtBox = document.getElementById('<%=TextBox1.ClientID %>');
            if (txtBox.value == "User Name") {
                txtBox.value = "";
                txtBox.style.backgroundColor = "white";
                txtBox.style.color = "Black"
            }
        }
        function onFoucsOut() {
            var txtBox = document.getElementById('<%=TextBox1.ClientID %>');
            if (txtBox.value == "") {
                txtBox.value = "User Name";
                txtBox.style.backgroundColor = "Azure";
                txtBox.style.color = "Silver";
            }
        }



HTML
<blockquote class="FQ"><div class="FQA">Quote:</div> ></blockquote>
 
Share this answer
 
v2
Comments
ntitish 28-Feb-13 5:12am    
this i can write on content page ha sir.....
Asim Mahmood 28-Feb-13 5:28am    
any where sir but you write Js code in js file.

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