Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8767483
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T16:49:29+00:00 2026-06-13T16:49:29+00:00

<asp:TextBox ID=TxtBOX runat=server CssClass=text Height=32px Width=360px TextMode=MultiLine TextWrapping=Wrap AcceptsReturn=True VerticalScrollBarVisibility=Visible onclick=if(this.value='<%=_data.Obsprevia.ToString()%>’){this.value=”} onblur=if(this.value=”){this.value='<%=TxtObservaciones.Text.ToString()%>’}> </asp:TextBox> That’s

  • 0
<asp:TextBox ID="TxtBOX" 
        runat="server"              
        CssClass="text"
        Height="32px" 
        Width="360px"  
        TextMode=MultiLine         
        TextWrapping="Wrap"
        AcceptsReturn="True"
        VerticalScrollBarVisibility="Visible"
        onclick="if(this.value='<%=_data.Obsprevia.ToString()%>'){this.value=''}"             
        onblur="if(this.value=''){this.value='<%=TxtObservaciones.Text.ToString()%>'}">

     </asp:TextBox>

That’s my code.

Default TxtBOX.Text comes from code behind (_data_obsprevia). What I want to achieve is, a clean up of that default text once the user clicks on the textbox. And if the txbox lose focus while the user didn’t write anything, get back that default text.

I can’t achieve that, and if the user DID write something, and lose-gain focus again, the textbox gets empty again.

Thanks.

EDIT

Fixed the == inside the IFs, Now it looks like this

<asp:TextBox ID="TxtBOX" 
        runat="server"              
        CssClass="text"
        Height="32px" 
        Width="360px"  
        TextMode=MultiLine         
        TextWrapping="Wrap"
        AcceptsReturn="True"
        VerticalScrollBarVisibility="Visible"
        onclick="if(this.value=='<%=_data.Obsprevia.ToString()%>'){this.value=''}"             
        onblur="if(this.value==''){this.value='<%=TxtObservaciones.Text.ToString()%>'}">

     </asp:TextBox>   

But when I first click on it, it’s not cleaning the deafult data. And if I erase it, and go losing focus it shows <%=TxtObservaciones.Text.ToString()%>
Not the value held inside of it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T16:49:30+00:00Added an answer on June 13, 2026 at 4:49 pm

    Try this, a build onto insertusernamehere’s suggestion..

    onclick="if(this.value=='<%=_data.Obsprevia.ToString()%>'){this.value=''}"             
    onblur="if(this.value==''){this.value=document.getElementById('<%= TxtObservaciones.ClientID %>').value}"
    

    This gets what is set in the textbox from javascript, in case it is changed in the browser.

    You also might need to break the code out into functions

         function TxtBOX_OnClick() {
             var TxtBOX = document.getElementById("<%= TxtBOX.ClientID %>");
             if (TxtBOX.value == "<%=_data.Obsprevia.ToString()%>") {
                 TxtBOX.value = '';
             }
         }
         function TxtBOX_OnBlur() {
             var TxtBOX = document.getElementById("<%= TxtBOX.ClientID %>");
             if (TxtBOX.value == '') {
                 TxtBOX.value = document.getElementById("<%= TxtObservaciones.ClientID %>").value;
             }
         }
    

    and

    onclick="TxtBOX_OnClick();"             
    onblur="TxtBOX_OnBlur();"             
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multiline textbox : <asp:TextBox ID=txtBody runat=server TextMode=MultiLine Rows=10 Width=95% /> In
I have a multi line text box like : <asp:TextBox CssClass=txtform ID=txtWhom runat=server Height=78px
<asp:TextBox ID=TextBox5 runat=server Height=30px Width=68px></asp:TextBox> <ajaxToolkit:DropDownExtender ID=TextBox5_DropDownExtender runat=server DynamicServicePath= Enabled=True TargetControlID=TextBox5> </ajaxToolkit:DropDownExtender> //this.TextBox5_DropDownExtender ????
I'm trying to use asp: <asp:TextBox ID=txtInput runat=server TextMode=MultiLine></asp:TextBox> I want a way to
Hi I have created user control for re-sizable text box. <asp:Panel ID=PanelText runat=server CssClass=frameText>
I want to get value of <asp:TextBox ID=txtTotalAmount CssClass=classTotalAmount number Columns=8 runat=server></asp:TextBox> from table.
<asp:TextBox ID=txt_Subject runat=server CssClass=txt_box></asp:TextBox> <asp:RequiredFieldValidator ID=valSubjectRequired ControlToValidate=txt_Subject ErrorMessage=Subject is a required field. EnableClientScript=true Display=None
I have an asp:TextBox that looks like the following <asp:TextBox runat=server AutoPostBack=True ID=txtG1 ontextchanged=txtG1_TextChanged
I have <asp:TextBox runat=server ID=lastName /> on a page and I want to set
If I have the following in an ASP.NET Web Form: <asp:TextBox runat=server ID=tbxUser/> and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.