Sharepoint web services + autocompleteextender

Oh boy that was fun.  I’m not even going to get into what I had to do and how long it took to get this working.  However, some code below will be helpful for those of you that want to try this yourselves (it’s not mine; I pulled it from the Smarttools source).  This solves the issue that Sharepoint has with Ajax postbacks/callbacks.

Also, you’re going to want to make sure that your “servicepath” attribute of the autocompleteextender is setup like this: “~/_vti_bin/nameofyourwebservice.asmx” or else you’ll get prompted to log in every time you call the service (which, incidentally, should be deployed to the ISAPI directory in your “12” hive).

If you need additional details, let me know.

ScriptManager sm = ScriptManager.GetCurrent(this.Page); if (sm == null) { //create new ScriptManager and EnablePartialRendering sm = new ScriptManager(); sm.EnablePartialRendering = true; sm.EnableScriptLocalization = true; // Fix problem with postbacks and form actions (DevDiv 55525) Page.ClientScript.RegisterStartupScript(typeof(AgencyCodePicker), this.ID, "_spOriginalFormAction = document.forms[0].action;", true); //tag:"form" att:"onsubmit" val:"return _spFormOnSubmitWrapper()" //blocks async postbacks after the first one //not calling "_spFormOnSubmitWrapper()" breaks all postbacks //returning true all the time, somewhat defeats the purpose of //the _spFormOnSubmitWrapper() which is to block repetitive postbacks, //but it allows MS AJAX Extensions to work properly //its a hack that hopefully has minimal effect if (this.Page.Form != null) { string formOnSubmitAtt = this.Page.Form.Attributes["onsubmit"]; if (!string.IsNullOrEmpty(formOnSubmitAtt) && formOnSubmitAtt == "return _spFormOnSubmitWrapper();") { this.Page.Form.Attributes["onsubmit"] = "_spFormOnSubmitWrapper();"; } //add the ScriptManager as the first control in the Page.Form //I don't think this actually matters, but I did it to be consistent //with how you are supposed to place the ScriptManager when used declaritevly this.Controls.AddAt(0, sm); } }