Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to get focus on TextBox after PostBack and Why Repeater control showing data when TextBox is empty?
    primarykey
    data
    text
    <p>I am working on a <code>C# ASP.NET 4</code> project where I need to have a search box that dynamically searches the content from database's table and shows it in <code>Repeater Control</code> everytime I enter alphabet in <code>TextBox</code>.</p> <p>I have done it upto this but the problem is <br/> <br/> 1) I am losing focus on <code>TextBox</code> everytime I enter single alphabet <br/> 2) When I erase content in <code>TextBox</code>, <code>Repeater Control</code> still shows data</p> <pre><code>&lt;asp:TextBox ID="TextBox1" runat="server" Width="90%" ontextchanged="TextBox1_TextChanged" onKeyUp="return serachme()" AutoPostBack="false"&gt;&lt;/asp:TextBox&gt; &lt;script language="javascript" type="text/javascript"&gt; function serachme() { __doPostBack('&lt;%=TextBox1.UniqueID %&gt;', "onKeyUp"); } &lt;/script&gt; </code></pre> <p>And,</p> <pre><code>protected void TextBox1_TextChanged(object sender, EventArgs e) { con.Open(); SqlDataAdapter mycommand2 = new SqlDataAdapter("select qid,title from globalq where title like '%" + TextBox1.Text + "%'", con); DataSet ds = new DataSet(); mycommand2.Fill(ds); askQ.DataSource = ds; askQ.DataBind(); con.Close(); } </code></pre> <p>I already saw examples of <a href="https://stackoverflow.com/questions/4033141/set-focus-in-textbox-after-postback">Set focus in TextBox after postback</a> and <a href="https://stackoverflow.com/questions/2690766/set-focus-on-textbox-after-postback">Set focus in TextBox after postback</a> but did not understood it coz I dont know <code>JavaScript</code> that much.</p> <p>So my Question is<br/><br/> 1) How to get focus on <code>TextBoX</code> everytime I <code>__doPostBack</code>?<br/> 2) When I erase content in <code>TextBox</code>, Why <code>Repeater Control</code> still shows data and how to not show that?</p> <p>Thanks for your efforts in advance,</p> <p>Nikhil</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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