Click here to Skip to main content
15,885,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
XML
<script type="text/javascript">
        
        aut(document).ready(function () {
            debugger;
            aut("#<%=txtfname.ClientID%>").autocomplete({
                source: function (request, response) {
                    debugger;
                    aut.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "Default.aspx/GetFacilityName",
                        data: "{'FacilityName':'" + document.getElementById("<%=txtfname.ClientID%>").value + "'}",
                        dataType: "json",
                        success: function (data) {
                            debugger;
                            response(data.d);
                        },
                        error: function (result) {
                            alert("Error");
                        }
                    });
                },
                select: function (event, ui) {
                    debugger;
                    var label = ui.item.label;
                    var value = ui.item.value;

                    aut.ajax({
                        type: "POST",
                        contentType: "application/json; charset=utf-8",
                        url: "Default.aspx/GetDetailsByFacName",
                        data: "{'FacilityName':'" + label + "'}",
                        contentType: "application/json; charset=utf-8",
                        dataType: "json",
                        success: function (data) {
                            debugger;

                            aut('#<%=ddloredringPhysician.ClientID%>').val(data.d[0]);
                            aut('#<%=lblphone.ClientID%>').val(data.d[1]);
                            aut('#<%=lblFax.ClientID%>').val(data.d[2]);
                            aut('#<%=lblContact.ClientID%>').val(data.d[3]);
                            aut('#<%=lblCourierName.ClientID%>').val(data.d[4]);
                            aut('#<%=lblCourierPhone.ClientID%>').val(data.d[5]);



                        },

                        error: function (data) {
                            debugger;

                        }
                    })








                }
            });
        });

    </script>


C#
[WebMethod]
        public static List<string> GetDetailsByFacName(string FacilityName)
        {
            FacilityBL objDB = new FacilityBL();
            if (!string.IsNullOrEmpty(FacilityName))
            {
                var facility = objDB.SelectAll().Where(x => (x.FacilityName.Contains(FacilityName)));
                List<string> strNamesData = new List<string>();
                foreach (var item in facility)
                {
                    strNamesData.Add(item.FacilityName);
                    strNamesData.Add(item.Phone);
                    strNamesData.Add(item.Fax);
                    strNamesData.Add(item.Contact);
                    strNamesData.Add(item.FacilityID);
                    strNamesData.Add(item.CourierName);
                    strNamesData.Add(item.CourierPhone);
                }
                return strNamesData.ToList();
            }
            else
            {
                return null;
            }
        }



I want to set web method value to label or dropdown controls at the same time.How to set the value after "Default.aspx/GetDetailsByFacName" method call to controls.

Thanks.
Posted
Updated 24-Aug-15 0:22am
v2
Comments
You have already written the code. What is the issue?
itsathere 16-May-15 3:17am    
it's was not working.Now, I have changed the code by making a new class object and providing data.d.ObjName and it's working fine.

Thanks.

1 solution

Answered only to remove from unanswered list - solved by OP.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900