by dotnetpete
24. September 2008 17:26
This is something that I've been meaning to delve into for a while now. I've used the AjaxControlToolkit AutoCompleteExtender a bit but until now I have never had to pass a runtime parameter through to the service method.
I found a post saying that the signature of the method must be the following:
[WebMethod] public string[] GetCountryOrStatesInfo(string prefixText, int count, string contextKey)
For some reason I took the signature part to mean parameters string, int, and string in that order. As it turns out the parameters must be named exactly prefixText, count and contextKey. You will also need UseContextKey="true" on the AutoCompleteExtender in your aspx as well.
In the example I was doing, the context key was state and on the selected index changed of a combo I was setting the context like this:
AutoCompleteExtender1.ContextKey = ddlState.SelectedValue;
One other point of note, the web service class itself must be decorated with [System.Web.Script.Services.ScriptService].
by dotnetpete
18. September 2008 16:18
Update panels are great. Once you use them once you will use them everywhere. Until you realise that they can be slower (or seem slower) than a regular full postback. I use popup panels quite a bit and I think you get more flow in your web apps because you don't have to change pages quite as much.
One thing that's been bugging me with update panels though is the fact that I couldn't do a response.write from a button that was in an update panel e.g. send a pdf report to the browsers response to allow the user to view or save. If you tried to do this you would get an error like the following:
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
After a bit of searching today I found one solution. Add the button into the update panels triggers section as a PostBackTrigger (as opposed to an AsyncPostBackTrigger you use when ChildrenAsTriggers is false).
Works a treat and allows me to keep the benfits of update panels.