[Solved] jQuery AutoComplete not working in Content page in ASP.Net

Last Reply one year ago By Mudassar

Posted one year ago


I am using autcomplete extender. my code for is in  Search_CS.ashx  file.

then in my search bar i call it as follow.

<link href="css/jquery.autocomplete.css" rel="stylesheet" type="text/css" />
<script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
<script src="Scripts/jquery.autocomplete.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function() {
 <div class="input-group search padding" onkeypress="return WebForm_FireDefaultButton(event, '<%= LinkButton1.ClientID %>')">
     <asp:TextBox ID="TextBox1" runat="server" CssClass="form-control" placeholder="Search Profile" ValidationGroup="search"></asp:TextBox>
      <span class="input-group-btn">
          <asp:LinkButton ID="LinkButton1"  OnClientClick="if (!Page_ClientValidate('search')){ return false; } this.disabled = true; this.value = 'Processing...';" UseSubmitBehavior="False" class="btn btn-default" runat="server" OnClick="LinkButton1_Click" ValidationGroup="search" CausesValidation="False"><i class="fa fa-search"></i></asp:LinkButton>

it works fine. the only problem is it works on Default page but i am in inner pages>  xyz.com/user/allusers   autocomplete extender does not work please advice

You are viewing reply posted by: Mudassar one year ago.
Posted one year ago Modified on one year ago

This is Path Issue.

As you have out code on Master Page. The Path changes. So you have to use ResolveUrl function so that automatically Path is set by .Net.

<link href='<%=ResolveUrl("~/css/jquery.autocomplete.css")%>' rel="stylesheet" type="text/css" />
<script src='<%=ResolveUrl("~/Scripts/jquery-1.4.1.min.js")%>' type="text/javascript"></script>
<script src='<%=ResolveUrl("~/Scripts/jquery.autocomplete.js")%>' type="text/javascript"></script>

 And for AutoComplete

<script type="text/javascript">
    $(document).ready(function() {