1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

ASP- Ajax

Discussion in 'C#' started by spm, Apr 21, 2009.

  1. #1
    Hi All,

    I am new to this place.
    I need help from anyone for implementing ajax in my project.

    I need to load some data as a list in Onchange/ Keyup event of
    <input type="text" name="txtsearch" value=""/>.

    Please see the attached file for more details...

    Please give me solution for this problem.

    Thanks in Advance.:)
    SEMrush
    Regards,
    spm.
     

    Attached Files:

    spm, Apr 21, 2009 IP
    SEMrush
  2. Divergence

    Divergence Peon

    Messages:
    30
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Well if you are doing .NET, then you can use the ASP.NET AJAX library, specifically the autocompletion control. See the asp.net/ajax site for samples (I can't post live links yet)
     
    Divergence, Apr 24, 2009 IP
  3. mavili

    mavili Active Member

    Messages:
    11
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    88
    #3
    you can do it using asp. search autocomplete scripts on the web.
    most of them are in php.
    just, apply to asp script for server side, it is not hard.
     
    mavili, May 6, 2009 IP
  4. seokingdom07

    seokingdom07 Banned

    Messages:
    132
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I have impletemented the same for some of my application using classic ASP
    Refernce code

    Code for file where list will be displayed
    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
    <html>

    <head>

    <script src="clienthint.js"></script>

    </head>

    <body>



    <form>

    Enter Word:

    <input type="text" id="txt1"

    onkeyup="showHint(this.value)">

    </form>



    <p>Suggestions: <span id="txtHint"></span></p>



    </body>

    </html>


    Javascript code

    var xmlHttp
    function showHint(str)

    {
    if (str.length==0)

    {

    document.getElementById("txtHint").innerHTML="";

    return;

    }

    xmlHttp=GetXmlHttpObject()

    if (xmlHttp==null)

    {

    alert ("Your browser does not support AJAX!");

    return;

    }

    var url="gethint.asp";

    url=url+"?q="+str;

    url=url+"&sid="+Math.random();

    xmlHttp.onreadystatechange=stateChanged;

    xmlHttp.open("GET",url,true);

    xmlHttp.send(null);

    }



    function stateChanged()

    {

    if (xmlHttp.readyState==4)

    {

    document.getElementById("txtHint").innerHTML=xmlHttp.responseText;

    }

    }



    function GetXmlHttpObject()

    {

    var xmlHttp=null;

    try

    {

    // Firefox, Opera 8.0+, Safari

    xmlHttp=new XMLHttpRequest();

    }

    catch (e)

    {

    // Internet Explorer

    try

    {

    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");

    }

    catch (e)

    {

    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");

    }

    }

    return xmlHttp;
    }


    ASP Code where you will fetch the list


    <%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>

    <%

    response.expires=-1

    Dim rsWords

    Dim rsWords_numRows

    Dim q

    Dim hint

    q=ucase(request.querystring("q"))

    hint=""

    Set rsWords = Server.CreateObject("ADODB.Recordset")

    rsWords.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("db_hint_words.mdb")

    rsWords.Source = "SELECT * FROM TBL_WORDS WHERE (word LIKE'" + q + "%') ORDER BY WORD"

    rsWords.CursorType = 2

    rsWords.CursorLocation = 2

    rsWords.LockType = 3

    rsWords.Open()

    rsWords_numRows = 0



    If Not rsWords.EOF Then

    Do While Not rsWords.EOF

    If trim(hint) = "" Then

    hint = rsWords("word")

    Else

    hint = hint & " , " & rsWords("word")

    End If

    rsWords.MoveNext()

    Loop

    End If

    if trim(hint)="" then

    response.write("no suggestion")

    else

    response.write(hint)

    end if



    rsWords.Close()

    Set rsWords = Nothing

    %>
     
    seokingdom07, May 17, 2009 IP
    frank.net likes this.
  5. samster7

    samster7 Banned

    Messages:
    170
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Thank you very much..I was looking for that only...:)
     
    samster7, May 18, 2009 IP
  6. spm

    spm Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Hi All,

    Thanks for ur help... :)

    Regards,
    SPM
     
    spm, May 29, 2009 IP