Monday, March 26, 2012

VS 2008 RTM AJAX Toolkit 3.5 Autocomplete extender has issues

I just installed VS 2008 RTM and the autocomplete has issues. I created a new page added the scriptmanager and set it up to enablepagemethod so that I could use my local database to supply the autocomplete strings.

I dropped a textbox on the page then I dropped the extender onto the control. It appeared in the properties list of the textbox as expected. I changed some properties and set the ServiceMethod.

The extender did not alter the source. All the property changes were lost. I tied this several times and always the same result. The properties could be changed in the properties window but these are not updated in the source aspx page. So when you switch to source view from design the changes are simply lost.

For those who would like to implement a pagemethod rather than a webservice call, I found two good sources:

http://allwrong.wordpress.com/2007/03/13/ms-ajax-autocomplete-extender-using-a-page-method/

http://fredrik.nsquared2.com/viewpost.aspx?PostID=393

From my codebehind page:
<* The autocomplete extender is designed to use a web service to supply the items for the list box. Sometimes this
* is certainly an over-kill or the data may be accessable directly from the application's database connection. A
* web service is an un-needed layer for these times. So here is how to call a "page method" to supply that data.
*
* 1 - add: using System.Web.Services;
* 2 - In the html, modify the ScriptManager with the EnablePageMethods set to true.
* ex: <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="True"></asp:ScriptManager>
* 3 - add a declaration for the page method: [WebMethod]
* 4 - add: public static string[] methodNameHERE(string prefixText, int count)
*
*/

///<summary>
/// ServiceMethod - The method to be called. The signature of this method must match EXACTLY as below.
///</summary>
///<param name="prefixText"></param>
///<param name="count"></param>
///<returns>string array</returns>
[WebMethod]
publicstaticstring[] getCompanyNames(string prefixText,int count)
{
bbCMScore bb =newbbCMScore();
string[] s = bb.getGroupingUsingUserCompanyNameSource(prefixText, count).ToArray();
return s;
}

The ASPX code looks like this:

<asp:TextBoxID="tbGrouping"runat="server"></asp:TextBox>
<cc1:AutoCompleteExtenderID="tbGrouping_AutoCompleteExtender"runat="server"EnableCaching="true" CompletionSetCount="20" CompletionListCssClass="autocomplete_completionListElement" CompletionListItemCssClass="autocomplete_listItem"CompletionListHighlightedItemCssClass="autocomplete_highlightedListItem" MinimumPrefixLength="2" TargetControlID="tbGrouping" ServiceMethod="getCompanyNames">
</cc1:AutoCompleteExtender>

The above works as it should. The problem is the properties are not updating. This causes VS 2008 RTM to error with a "souce code not available" error which certainly doesn't point to the real problem. You thought you set the properties and really they were not set.

Larry Aultman

Hi Larry,

Your problem is such weird issue. Can you modify or add extra code to your page? We suggest that you should check which version of AJAX Control Toolkit that you are using now. Please upgrade it to V11119. Also, you should check the .NET Framework version and AJAX Control Toolkit version. So do the web.config settings. AJAX Control Toolkit are divided into two versions for supporting .NET Framework 2.0 and 3.5.

Best regards,

Jonathan


Jonathan,

During the upgrade to RTM from Beta 2, I uninstalled everything Beta2. I uninstalled all projects from my machine, and deleted all traces of my development environment. I installed the RTM, downloaded the latest versions of AJAX toolkit. I created an new project.

I did verify that all my versions are for 3.5. My work around is to just not use the properties window for the control. However this control has other isses that are show-stoppers. I have commented on them in this forum under the "onClientItemSelected" event that will not fire. I can make it autocomplete but I can't get an event fired so it isn't much use to me. Thus for the moment I can't use it in production.

Thanks for the reply. I hope that someone is able to find the problem as it would be useful to users.

Larry Aultman


Hi Larry,

wph101larrya:

My work around is to just not use the properties window for the control.

Only for AJAX Contol Toolkit's Controls or all the Controls?

If the former, please do this and have a test.

We suggest that you should download a sample fromhttp://www.asp.net/learn/ajax-videos/ and have a test. Please make sure Javascript is not forbidded in you machine.

Best regards,

Jonathan

No comments:

Post a Comment