Note that there are some explanatory texts on larger screens.

plurals
  1. POTextbox value onclick onblur issue
    primarykey
    data
    text
    <pre><code>&lt;asp:TextBox ID="TxtBOX" runat="server" CssClass="text" Height="32px" Width="360px" TextMode=MultiLine TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" onclick="if(this.value='&lt;%=_data.Obsprevia.ToString()%&gt;'){this.value=''}" onblur="if(this.value=''){this.value='&lt;%=TxtObservaciones.Text.ToString()%&gt;'}"&gt; &lt;/asp:TextBox&gt; </code></pre> <p>That's my code.</p> <p>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.</p> <p>I can't achieve that, and if the user DID write something, and lose-gain focus again, the textbox gets empty again.</p> <p>Thanks.</p> <p><strong>EDIT</strong></p> <p>Fixed the == inside the IFs, Now it looks like this</p> <pre><code>&lt;asp:TextBox ID="TxtBOX" runat="server" CssClass="text" Height="32px" Width="360px" TextMode=MultiLine TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Visible" onclick="if(this.value=='&lt;%=_data.Obsprevia.ToString()%&gt;'){this.value=''}" onblur="if(this.value==''){this.value='&lt;%=TxtObservaciones.Text.ToString()%&gt;'}"&gt; &lt;/asp:TextBox&gt; </code></pre> <p>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 <code>&lt;%=TxtObservaciones.Text.ToString()%&gt;</code> Not the value held inside of it.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload