25-May-15
Log In
Products
SUPPORT CENTER
Buy
Support
Tickets
My Account
Examples
About Us
Localization
FAQ
Training Events
ID:
E3778
Mo dified O n :
1/27/2015 4:38:40 PM
Scenario:
Tech n o lo gy:
.NET
It is necessary to execute server-side code that requires refreshing the current View as a response to user actions in an ASP.NET application.
For example, show the first navigation item when a new navigation group is selected.
Platfo rm:
Framew o rks (XAF & XPO )
Pro du ct:
eXp ressAp p Framew o rk
Steps to Implement:
1. Create a Controller that implements the IXafCallbackHandler interface. This interface allows defining server-side code that is executed
when an XAF callback is raised.
2. Place the required server-side code to the IXafCallbackHandler.ProcessAction method, e.g. change ShowNavigationItemAction's selected
item.
3. Subscribe to the Window.ProcessActionContainer event to access a navigation control (NavigationTabsActionContainer).
4. Raise an XAF callback by passing javascript generated by the XafCallbackManager.GetScript method to
the NavigationTabsActionContainer.PageControl.ClientSideEvents.ActiveTabChanged event handler.
5. Register your callback handler (Controller) using the XafCallbackManager.RegisterHandler method.
Downloads
Examp le
Examp le Ru n n er
See also:
How to implement the drill-down functionality in Web PivotGrid (ASPxPivotGrid)
Leave a Comment
AutoSelectNavigationItemController.cs
C#
using System;
using
using
using
using
using
using
DevExpress.ExpressApp;
DevExpress.ExpressApp.Actions;
DevExpress.ExpressApp.Web.Templates.ActionContainers;
DevExpress.ExpressApp.Web.Templates;
DevExpress.ExpressApp.Web;
DevExpress.ExpressApp.SystemModule;
namespace NavBarExample.Module.Web.Controllers {
public class AutoSelectNavigationItemController : WindowController, IXafCallbackHandler {
public AutoSelectNavigationItemController() {
TargetWindowType = WindowType.Main;
}
protected override void OnActivated() {
base.OnActivated();
Window.ProcessActionContainer += Window_ProcessActionContainer;
}
protected override void OnDeactivated() {
Window.ProcessActionContainer -= Window_ProcessActionContainer;
base.OnDeactivated();
}
void Window_ProcessActionContainer(object sender, ProcessActionContainerEventArgs e) {
if (e.ActionContainer is NavigationTabsActionContainer) {
NavigationTabsActionContainer navActionContainer = e.ActionContainer as NavigationTabsActionContainer;
navActionContainer.PageControl.EnableClientSideAPI = true;
XafCallbackManager callbackManager = ((ICallbackManagerHolder)WebWindow.CurrentRequestPage).CallbackManager;
callbackManager.RegisterHandler("NavBarViewChangingController", this);
navActionContainer.PageControl.ClientSideEvents.ActiveTabChanged = string.Format("function(s, e){{{0}}}", callbackManager.GetScript("NavBarViewChangingContro
}
}
#region IXafCallbackHandler Members
public void ProcessAction(string parameter) {
int tabIndex = Int32.Parse(parameter);
SingleChoiceAction showNavigationItemAction = Frame.GetController<ShowNavigationItemController>().ShowNavigationItemAction;
showNavigationItemAction.DoExecute(showNavigationItemAction.Items[tabIndex].Items[0]);
}
#endregion
}
}
DEVEXPRESS
About Us
News
.NET CONTROLS
WinForms
ASP.NET
https://www.devexpress.com/Support/Center/Example/Details/E3778
MOBILE
DevExtreme Mobile
HTML5 JS WIDGETS
DevExtreme Web
SUPPORT
Search the Knowledge Base
My Questions
1/2
E3778 - How to raise XAF CallBacks from client-side events | DevExpress Support Center
Our Awards
Upcoming Events
User Comments
Case Studies
Reviews and Publications
Licensing
Purchasing
MVP Program
Contact Us
Logos
MVC
WPF
Silverlight
Windows 8 XAML
CROSS PLATFORM
Reporting
Document Automation
ENTERPRISE TOOLS
Report Server
Analytics Dashboard
FRAMEWORKS
eXpressApp Framework
CODE-DEBUG-REFACTOR
CodeRush for Visual Studio
25-May-15
iOS 7
DataExplorer
FUNCTIONAL WEB TESTING
TestCafe
DELPHI C++BUILDER
VCL
Code Examples
Getting Started
Demos
Documentation
Blogs
Training
Webinars
Current Version/Build
Version History
FOLLOW US
If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383
https://www.devexpress.com/Support/Center/Example/Details/E3778
2/2