Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...AutoComplete in DNN using Web Services in aspxAutoComplete in DNN using Web Services in aspx
Previous
 
Next
New Post
12/17/2018 10:36 AM
 
This is a simple Auto Complete  in DNN using Web Services in aspx, which I just learned, this example will require Northwind connection

1. get to know the AutoComplete from https://www.aspsnippets.com/Articles/....
2. get to know the Using Ajax with jQuery from https://sites.google.com/site/lagater...

a. Create new module, in this example is DNN_Ajax
b. Make sub folder Services
c. Copy Default.aspx, Default.aspx.cs to folder Services (step b), change filename from Default to AutoComplete, update Namespace in the files
d. From your view user control (VIEW.ASCX), add the Text box (copy and modify from step 1)

<div>
    Enter search term:
    <asp:TextBox ID="txtSearch" runat="server" />
    <asp:HiddenField ID="hfCustomerId" runat="server" />
    <asp:Button ID="Button6" Text="Submit" runat="server" OnClick="Submit" />
</div>

e. add the script (copy and modify from step 1) to VIEW.ASCX

 

<script type="text/javascript">
    $(function () {
        $("[id$=txtSearch]").autocomplete({
            source: function (request, response) {
                $.ajax({
                    url: '<%=ResolveUrl("~/DesktopModules/DNN_Ajax/Services/AutoComplete.aspx/GetCustomers"%>',
                        data: "{ 'prefix': '" + request.term + "'}",
                        dataType: "json",
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        success: function (data) {
                            response($.map(data.d, function (item) {
                                return {
                                    label: item.split('-')[0],
                                    val: item.split('-')[1]
                                }
                            }))
                        },
                        error: function (response) {
                             response.responseText);
                        },
                        failure: function (response) {
                             response.responseText);
                        }
                    });
                },
                select: function (e, i) {
                    $("[id$=hfCustomerId]").val(i.item.val);
                },
                minLength: 1
            });
        });
</script>

f. Add the command to code behind for verify information

protected void Submit(object sender, EventArgs e)
{
    string customerName = Request.Form[txtSearch.UniqueID];
    string customerId = Request.Form[hfCustomerId.UniqueID];
    ScriptManager.RegisterStartupScript(Page, this.GetType(), "alert"" ame: " + customerName + "\\nID: " + customerId + "');"true);
}


Hope it help!

 
New Post
12/17/2018 3:29 PM
 
A complete sample file is at https://github.com/tinboen/DNNAutoCom.... Happy Programming!
 
Previous
 
Next
HomeHomeOur CommunityOur CommunityGeneral Discuss...General Discuss...AutoComplete in DNN using Web Services in aspxAutoComplete in DNN using Web Services in aspx


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out