0

I have a TextBox and I want to capture the Keyup in the Textbox and get the TextBox value at the Code Behind File and Bind The GridView with the Input Received from the TextBox.

I don't want to use Text_Change Event of Asp.net. i want that when ever user enter anything in the TextBox, that value should go to code behind and bind the grid by calling BindGrid Function

<asp:TextBox ID="txtSearch" runat="server"></asp:TextBox>

protected void BindGrid(string searchvalue)
{    
    //  i want the txtSearch value over here.    
}
Ian R. O'Brien
  • 6,682
  • 9
  • 45
  • 73
Moiz
  • 2,409
  • 5
  • 27
  • 50
  • Do you need somthing like this? http://stackoverflow.com/questions/13803569/how-to-handle-keydown-event-in-asp-net-textbox/13804562#13804562 If Yes I can remake it for your code. – Boriss Pavlovs Dec 18 '12 at 18:32

1 Answers1

0

You need to use asp.net ajax. Putting your button and grid in UpdatePanel will update the gridview after binding on button click.

In html

<asp:UpdatePanel runat="server" ID="updatePanel">
<asp:TextBox runat="server" ID="search"  
                ClientIDMode="Static" OnKeyUp="refreshPanel(this);" />

In javascript

function refreshPanel(textbox) {
     alert(this.value)
    __doPostBack('<%= updatePanel.UniqueID %>', this.value);
}

In code behind

 string parameter = Request["__EVENTARGUMENT"];
Adil
  • 146,340
  • 25
  • 209
  • 204