Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You should do it on <strong>client side</strong> (edit: as suggested by MightyLampshade you can find on of 1000 examples <a href="https://stackoverflow.com/questions/4135818/how-to-clear-a-textbox-using-javascript">here</a>), you do not need a round-trip to server for that. If you have, let's say, a clear button:</p> <pre><code>$("#clear").click(function() { $(".can-be-cleared").val(""); }); </code></pre> <p>Please note that this will clear all elements with class <code>can-be-cleared</code> (I assume you may do not want to clear each input but a specific set, if it's not the case just replace it with <code>input[type=text]</code>).when you click an element with id <code>clear</code>.</p> <p>If each "clear" button has to be tied with a single specific text box then you have to repeat them (because when you click on the button textbox won't be focused any more). As alternative you may <em>remember</em> last focused text box. Let's see both:</p> <pre><code>&lt;input type="text" id="textbox1"/&gt; &lt;button class="clear-button" data-textbox="textbox1"&gt;clear&lt;/button&gt; </code></pre> <p>JavaScript for this is:</p> <pre><code>$(".clear-button").click(function() { $("#"+$(this).data("textbox")).val(""); }); </code></pre> <p><strong>Simpler alternative</strong> (I prefer this if you do not have any other special requirement) may be to keep track of last focused textbox:</p> <pre><code>var lastFocused = undefined; $("input[type=text]").focus(function () { lastFocused = $(this); }); $("#clear-field").click(function () { if (lastFocused !== undefined) { lastFocused.val(""); } }); </code></pre> <p>Of course do not forget to match <code>$("#clear-field")</code> with right ID you used for your clear button, in this case I assume:</p> <pre><code>&lt;button id="clear-field"&gt;Clear&lt;/button&gt; </code></pre> <p>Anyway if you really need some server side processing (for any other reason), <code>TextBox</code> that generated event is in <code>sender</code> parameter:</p> <pre><code>Dim textbox As TextBox = DirectCast(sender, TextBox) textbox.Text = String.Empty </code></pre>
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      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