views:

435

answers:

1

I am using AutoComplete Extender from Ajax control tool kit. I have a webservice that this extender uses. In the web method I need to access a value "empid" which is present in my aspx page. I placed this value in HttpContext's Items collection in my aspx page.

HttpContext.Items["empid"]=;

In the web method I am trying to access the same using

string s=Context.Items["empid"];

But Items collection does not have any item there. Is this due to the partial postback the autocomplete extender control is doing.

Can some one help?

A: 

The AutoComplete Extender uses a web method with a specific signature (explained in the documentation) on a web service. This will be called from the browser using JavaScript (behind the scenes).

The web service and its web method know nothing about your page - they only know the information that is passed to them in the arguments of the web method.

Richard Ev
Thanks Richard for the response. However I still have a doubt. I am able to access the Cache object in this web method. I am using it as belowContext.Cache["key"]. And I am curious to know how this works then?
Calling Context.Cache["key"] will simply return null if no item called "key" exists, so I think that's what you're seeing.
Richard Ev
No Richard I am getting proper values in Context.Cache["key"]. Actually I added Cache["somekey"]=value and HttpContext.Items["empid"]=value during page_init event. I am getting proper values when I access Context.Cache in web method but when I try accessing Items I dont get them.
I don't understand what you mean Deepa - however from a design point of view I would say that the web method should not rely on data in your cache, unless it put the data there itself.
Richard Ev
Here's my design. The autocomplete extender is using a web method. This web method is searching strings from a cache object which is already populated. Please share your thoughts on this.
Also coming to my doubt now, you said the web method know nothing about my page which is why it does not know Context.items["key"] and which is why I get null in web method. However i observed that it knows Context.Cache["key"] and give me proper value there but not for Context.Items[] .Thoughts?
What are you caching, and why? If you are caching for performance reasons, have you proven that you actually have a performance issue and that it is resolved by caching?
Richard Ev
Yes that's right we have performance issues and which is why we are caching.
I think you need to store your cached data in your database in a rapid-to-query form, and access it from your web service call. I'm assuming that you have a database query that is your bottleneck...
Richard Ev