This is a migrated thread and some comments may be shown as answers.

The server method ... failed

7 Answers 304 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Curt
Top achievements
Rank 1
Curt asked on 09 Aug 2011, 10:47 PM
I have a large dataset that I am filling a combobox with via web service.  The dropdown and service work, but when I select an item from the dropdown I get "The server method MyMethod failed ", then the page processes and completes the request just like it should. Does anyone have any suggestions on how to stop the error box from popping up? or stop it from erroring at all. Any help would be great.
Thanks

    [WebMethod]
    public RadComboBoxData GetAltIdId(RadComboBoxContext context)
    {
        string sql = "SELECT  ALTID, ID FROM PEOPLE WHERE ID LIKE @text + '%'";
 
        SqlDataAdapter adapter = new SqlDataAdapter(sql,
            ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        DataTable data = new DataTable();
 
        adapter.SelectCommand.Parameters.AddWithValue("@text", context.Text);
        adapter.Fill(data);
 
        List<RadComboBoxItemData> result = new List<RadComboBoxItemData>(context.NumberOfItems);
        RadComboBoxData comboData = new RadComboBoxData();
        try
        {
 
            int itemsPerRequest = 10;
            int itemOffset = context.NumberOfItems;
            int endOffset = itemOffset + itemsPerRequest;
            if (endOffset > data.Rows.Count)
            {
                endOffset = data.Rows.Count;
            }
            if (endOffset == data.Rows.Count)
            {
                comboData.EndOfItems = true;
            }
            else
            {
                comboData.EndOfItems = false;
            }
            result = new List<RadComboBoxItemData>(endOffset - itemOffset);
            for (int i = itemOffset; i < endOffset; i++)
            {
                RadComboBoxItemData itemData = new RadComboBoxItemData();
                itemData.Text = data.Rows[i]["ID"].ToString();
                itemData.Value = data.Rows[i]["ALTID"].ToString();
 
                result.Add(itemData);
            }
 
            if (data.Rows.Count > 0)
            {
                comboData.Message = String.Format("Items <b>1</b>-<b>{0}</b> out of <b>{1}</b>", endOffset.ToString(), data.Rows.Count.ToString());
            }
            else
            {
                comboData.Message = "No matches";
            }
        }
        catch (Exception e)
        {
            //comboData.Message = e.Message;
        }
 
        comboData.Items = result.ToArray();
        return comboData;
    }}
-----------------------------------------------
<script type="text/javascript">
    function OnClientItemsRequesting(sender, eventArgs) {
        var context = eventArgs.get_context();
        context["FilterString"] = eventArgs.get_text();
    }
 
</script>
<telerik:RadComboBox runat="server" ID="RadComboBox1" OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"
    OnClientItemsRequesting="OnClientItemsRequesting" EnableLoadOnDemand="true" ItemsPerRequest="10"
    ShowMoreResultsBox="True" EnableVirtualScrolling="True" Filter="Contains" EmptyMessage="Enter A#"
    AppendDataBoundItems="true" AutoPostBack="true">
    <WebServiceSettings Method="GetAltIdId" Path="../PeopleSearch.asmx" />
</telerik:RadComboBox>
--------------------------------
    protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string url = Path.GetFileName(Request.Path);
        url += "?HNUMBER=" + RadComboBox1.SelectedValue.ToString();
        Response.Redirect(url);
    }

7 Answers, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 12 Aug 2011, 03:01 PM
Hello Curt,

Do you reproduce the issue under IIS only? Does it work under Cassini?
You may try to troubleshoot the problem as described here.

Kind regards,
Helen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Curt
Top achievements
Rank 1
answered on 13 Aug 2011, 12:26 AM
Sorry for my ignorance, but I'm not sure what Cassini is. I'm a student just starting to learn programming and this is my first web service project. 

~Curt
0
Helen
Telerik team
answered on 15 Aug 2011, 02:21 PM
Hello Curt,

Cassini is the default Visual Studio web server. It starts when yo open a page to view it in a browser.

Greetings,
Helen
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our
AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
y_farhan
Top achievements
Rank 1
answered on 10 Jan 2012, 11:37 AM
hi
i am having the same error. it works fine on my localhost but after deployment on IIS it is throwing popup "server  method "xyz" failed".Please help
0
Helen
Telerik team
answered on 11 Jan 2012, 09:34 AM
Hello,

Probably you will find helpful the following forum thread which discusses a similar problem:
http://www.telerik.com/community/forums/aspnet/combobox/how-to-debug-webservice-call.aspx

Regards,
Helen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
y_farhan
Top achievements
Rank 1
answered on 12 Jan 2012, 05:29 AM
Thanks Helen for the reference, but the solution ( i. to add line [System.Web.Script.Services.ScriptService]  ) has already been added to my code and it was working fine earlier, it stopped working after we deployed the application on another server.
Do you have any idea why it is behaving like this??

Thanks & Regards
0
Helen
Telerik team
answered on 12 Jan 2012, 03:27 PM
Hi,

We believe that the reason for the error is something related to the Ajax settings on your server. Do you use any Ajax functionality with success? Are you able to create an Ajax postback?


Regards,
Helen
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
ComboBox
Asked by
Curt
Top achievements
Rank 1
Answers by
Helen
Telerik team
Curt
Top achievements
Rank 1
y_farhan
Top achievements
Rank 1
Share this question
or