-
Plain English Programming
-
From a discussion on CodeProject something definitely worth checking out. Take a look at the sample application... and the source code!
https://www.osmosian.com/
-
ASP.NET Ajax UpdatePanelNotifier Builtin Effects
-
Yesterday I wrote about a control I've written which lets you bind javascript functions to UpdatePanel's partial postbacks. I've been working on it some more today and I enhanced it with some builtin effects which can be applied to the UpdatePanel which is refreshed using the combination effects of the script.aculo.us library. The behavior is similar to the UpdatePanelAnimation control extender which can be found in the AjaxControlToolkit but this is easier to use and more flexible in that only the UpdatePanel which is actually refreshed is applied the effect. Furthermore using the Animation framework available with the toolkit can be tricky.
The control API becomes:
- OnBeginRequest and OnEndRequest properties: enum of type ClientAction
- CustomBeginRequest and CustomEndRequest properties: string which accepts the name of a javascript function declared in the page
The ClientAction enum defines the following values:
- Custom
- Appear
- Fade
- ... [all the script.aculo.us combination effects]
The behavior is as following:
- When an effect is specified via the OnBeginRequest and OnEndRequest properties the corresponding effect is applied to the UpdatePanel which is being refreshed during the corresponding event
- When the value of one of those properties is set to Custom you can specify via the CustomBeginRequest and/or CustomEndRequest properties the name of a custom javascript function declared in your page which is called in response to the correspondng event (the function accepts as input parameter an DOM element which is the DIV element of the UpdatePanel as rendered in the browser).
- If you don't want to do anything just set OnxxxRequest to Custom and leave the corresponding CustomxxxRequest empty.
The source code is available on my main project's svn repository.
-
ASP.NET Ajax UpdatePanelNotifier: get notified of partial updates
-
UPDATE: The control has been added new features, check it out here.
Sometime ago I wrote a post about how to get the ID of the UpdatePanel which triggered an asynchronous postback using the ATLAS July CTP and how to execute a custom Javascript function whenever the postback initiated and when it sent back its results. With the release of ASP.NET Ajax Extensions Beta the API has changed a lot and that code is no longer working, while he new API exposes now a whole new set of facilities which make it really easier to achieve the same functionality.
I wrote the control I once called UpdateProgressSignup from scratch and changed its name to a more meaningful one: UpdatePanelNotifier. What this control does is very similar to the UpdateProgress standard control, in that it executes some client-side code whenever a partial update is triggered and when the results are returned from the server. The difference is that instead of executing a determined function (showing and hiding a <div> element by manipulating the DOM) you can bind your custom javascript functions to those events, which in turn receive as input parameter the concerned UpdatePanel DOM element so that you can directly act on it, making it blink when the beginRequest event is fired and then shake when the endRequestEvent is fired, for example.
The control exposes the same properties as the standard UpdateProgress control beyond two new properties which let you enter the name of the functions you want to execute:
- OnBeginRequest
- OnEndRequest
Each function executed in response to those events will be passed the DOM element of the UpdatePanel concerned in the partial update, so that if you set the OnBeginRequest property to "alertPanelId", you'll have to write a javascript function called "alertPanelId" in you page which will have the following signature and will eventually do something like this:
function alertPanelId(panelElement)
{
alert(panelElement.id);
}
Note that the bound functions will be called only when the partial refresh is triggered by a control inside the UpdatePanel and not when it's an external trigger doing it, since in this case it's not yet possible to retrieve the Id(s) of the UpdatePanel(s) which will be refreshed in response to that action. Anyhow it seems that the ASP.NET Ajax Team is working on it and will eventually provide this facility in the final release.
You can watch a short screencast to get started fast. The source code is available on my main project's svn repository.
-
ASP.NET Ajax EnhancedUpdateProgress - choose the position of your UpdateProgress!
-
I've been playing with the new bits of the ASP.NET Ajax framework lately; I like the enhancements pretty much, a much cleaner code and a very richer API to have fun with.
Since with the Beta 2 the UpdateProgress control is bundled into the main assembly I chose to enhance it a bit so that I can choose where to show it in my page. I inherited from the UpdateProgress control and exposed an additional property called Position, which accepts the following values:
- Center (default)
- TopLeft
- TopRight
- BottomLeft
- BottomRight
- None (same position as in the standard UpdateProgress, that is, where placed in the page)
I've recorded a short screencast to show how it works, and the source code is available on my main project's svn repository.