0

In my project i am using Textbox inside updatepanel to display the Receipt number which is not already exist in db table. But the textchanged event on the textbox is not firing while typing. My Logic is to display available receipt while typing. If nothing displayed then user can insert that receipt number.

<asp:UpdatePanel ID="updAvailableReceipt" runat="server">
     <ContentTemplate>
         <asp:TextBox ID="txtReceiptNo" runat="server" class="textBoxStyle" AutoPostBack="true" OnTextChanged="txtReceiptNo_TextChanged"></asp:TextBox>
         <asp:GridView ID="grdShowAvailableReceipt" runat="server" EnableTheming="True" ShowHeader="False"></asp:GridView>
     </ContentTemplate>
     <Triggers>
          <asp:AsyncPostBackTrigger ControlID="txtReceiptNo" EventName="TextChanged" />
     </Triggers>
</asp:UpdatePanel>

protected void txtReceiptNo_TextChanged(object sender, EventArgs e)
{
    param = ParameterClass.IniliazeParameter(1);
    int count=0;
    ParameterClass.AddParameter(ref param, "@ReceiptNumber", txtReceiptNo.Text, ref count);
    grdShowAvailableReceipt.DataSource = new bAuctionPayment().Fetch(RecordFetchMode.FethcAvailableReceipt, param);
    grdShowAvailableReceipt.DataBind();
}

This question is already exist but not answered yet...

Suhaib Janjua
  • 3,538
  • 16
  • 59
  • 73
jeevacl
  • 109
  • 1
  • 12

2 Answers2

1

Textchanged event will not get fired while you are typing. It will get fired when you lose focus so your code is fine just that you are expecting something which is never going happen. Try combining jquery ajax calls instead of updatepanel if you want a partial update of your page. Will try and give you an example here in some time.

Hope this helps (for the time being :))

P.S.: I am wondering why have you added asp.net mvc tag for this question.

EDIT:

The link here has an example which you can download. This example is pretty similar to what you are trying to achieve. Check it out.

Also just as Saurabh mentioned, you can use "keyup" event of the textbox in jquery to make the ajax call given in the link. The following is the code for the same.

        $('#<%= TextBox1.ClientID %>').keyup(function () { 
        //Make ajax call here
        alert('hi'); });
samar
  • 5,021
  • 9
  • 47
  • 71
0

You can use the Ajax AutoCompleteExtender for that particular textbox.

<asp:TextBox ID="textbox1" runat="server" AutoPostBack="true"></asp:TextBox>
<asp:AutoCompleteExtender ID="textbox1_AutoCompleteExtender" runat="server" CompletionInterval="1" 
CompletionSetCount="10" DelimiterCharacters="" Enabled="True" MinimumPrefixLength="1"
ServiceMethod="CreateAWebServiceMethod" 
ServicePath="FilePathWhichContainsTheWebServiceMethod" TargetControlID="textbox1" UseContextKey="True">
</asp:AutoCompleteExtender>

Service method is your WebServiceMethod which you want to fire when you start typing in the textbox1.

Service path is the path of the file which contains your web service method.

Mirage
  • 45
  • 1
  • 4
  • 12