Hello,
I'm trying to figure out what the best approach to a new project is. I'd like to write a custom control that, when I drop it on a page will (among other things) emit JavaScript code that will enable the control to make an AJAX call to one of it's own functions that retrieves data from the Cache object and updates a Label control with the data.
I'm not sure what mechanism I should use to accomplish this, though. WCF and Web Services both require an external .asmx or .svc file and the manual registration of the service with the ScriptManager. I'd like to find a way to keep this completely encapsulated within the DLL so that I can use in it various projects.
I can do this all without a custom control just fine by following these steps:
1) Create a WCF service inside my web project that has a method called GetCacheData which retrieves a value from the Cache object and returns it.
2) Putting a button on my page that calls a JavaScript function which in turn makes a call to the the WCF service.
3) In the callback function, setting the innertext of a DIV element with the value returned from the WCF service.
What I really want to be able to do is to take all of this and encapsulate it in a single control that could be placed on a page like so:
<MyControls:GetFromCache ID="MyControl1" TriggerButton="Button1" ResultControl="Label1" runat="server" />
The TriggerButton attritube would designate which button the user has created that should actually execute the WCF call and ResultControl would specify which control the results should be printed to.
I can handle all of that just fine, I'm just trying to give you an idea of what I'm doing in general. I'm just not sure how to go about encapsulating this all into a single control.
Thanks for any help.
Scott M Schluer
---
MCPD: ASP.NET Developer 3.5
