Question

I have this service for autocomplete extender that works for 'h' for prefixText and 3 for count and returns 'hi' and 'hello' in an array:

[System.Web.Services.WebMethod]
    [System.Web.Script.Services.ScriptMethod]
    public string[] GetWebUploadAutoCompleteData(string prefixText, int count)
    {
        try
        {
            DAL.DAL dal = new DAL.DAL();
            string[] returnValues = dal.GetWebUploadAutoCompleteData(prefixText, count);
            return returnValues;
        }
        catch (Exception ex)
        {
            throw new Exception(ex.Message);
        }
    }

the service class first lines:

...
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[System.Web.Script.Services.ScriptService]
public class BLL : System.Web.Services.WebService
{
...

and this is the UI:

<asp:TextBox ID="txtTest" runat="server" Width="250px"></asp:TextBox>
                <cc1:AutoCompleteExtender ID="aceTest" runat="server" CompletionSetCount="3" DelimiterCharacters=";, :"
                    ServicePath="http://localhost:7051/UploadServices/BLL.asmx" MinimumPrefixLength="2" 
                    Enabled="true" ServiceMethod="GetWebUploadAutoCompleteData" TargetControlID="txtTest">
                </cc1:AutoCompleteExtender>

everything is correct but it is not working, please help.

Was it helpful?

Solution

As you said that your webservice and UI are seprate project so that you can't call a service that is in a different domain than the page which hosts your client-code. This is a security feature, to prevent malicious code from redirecting your harmless javascript to something nasty on the world wide web.

Solution

To access the external web service, you can build a third web service proxy in your UI project. The third service can access the external web service from server-side, and you can access this internal web service from client.

Please let me know if you have any doubts.

EDIT

If you have created proxy service in your project.Do one more thing,add following code on the page

<asp:ScriptManager ID="ScriptManager1" runat="server">

            <Services>

                <asp:ServiceReference Path="AutoComplete.asmx" />

            </Services>

        </asp:ScriptManager>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top