Quantcast
Channel: DevExpress Support Center (Examples)
Viewing all 7205 articles
Browse latest View live

ASPxGridView - How to merge cells horizontally

$
0
0
Starting with version v2016 vol 1 (v.16.1), it became possible to merge cells using functionality available out of the box. Refer to the Cell Merging demo for more information. This one provides only vertical merging.

This example demonstrates a possible way of merging cells in the ASPxGridView control horizontally when adjacent cells in a row with the same values are merged. To do this, you can use the HtmlRowCreated and HtmlDataCellPrepared events.
Please keep in mind that functionality such as batch edit mode, grouping and fixed columns may not work as expected.

How to create a chart to visualize data in a Snap report

$
0
0
This example demonstrates how to use the Snap Chart API to add a chart to a report document programmatically.


Use the SnapDocument.CreateSnChart method to insert a chart into a document. This method returns the SnapChart object, which represents the newly created chart and provides properties used to populate the chart with data and fine-tune its layout and appearance settings. 
Use the SnapChart.DataSource property to bind the chart to data.
To provide data to the chart series, assign the data field containing series names to the SnapChart.SeriesDataMember property and specify the argument and value data members of the SeriesBase object returned by the SnapChart.SeriesTemplate property.

OBSOLETE - How to raise XAF callbacks from client-side events and process them on the server?

$
0
0

============================================================
This example is now obsolete. Refer to the How to: Raise XAF Callbacks from Client-Side Events and Process these Callbacks on Server topic for more details.
============================================================

Scenario:

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.

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.

See also:
How to implement the drill-down functionality in Web PivotGrid (ASPxPivotGrid)
How to automatically refresh data in a View after a certain period of time on the Web
Task-Based Help > How to: Open a Detail View When the Grid Row is Clicked in the Dashboard

ODataContext - How to filter data by a foreign key value

$
0
0

Sometimes it is required to filter some entities by a foreign key value.

This example demonstrates how to select all products that are associated with a required category. The Product entity has the Category navigation property. To filter products by the category ID, we need to expand the Category property using the ODataStore.expand option. In this case, we will be able to access a key field of a navigation property. This example operates with the Northwind online OData service. We can determine that Category is a navigation property of the Product one by typing the following URL in our browser "http://services.odata.org/Northwind/Northwind.svc/$metadata". See a screenshot below.


 

In this case our code should be as follows:

[JavaScript]
TestExpand.db = new DevExpress.data.ODataContext({ url: "http://services.odata.org/Northwind/Northwind.svc", errorHandler: function(error){ alert(error.message);}, entities: { Products: { key: "ProductID"}}});var viewModel = { dataSource: new DevExpress.data.DataSource({ store: TestExpand.db.Products, select: ['ProductID', 'ProductName', 'Category.CategoryID', 'Category.CategoryName'], expand: ['Category'], filter: ['Category.CategoryID', '=', 5]})};

 

OBSOLETE - ASPxGridView - How to focus cells from top to bottom by Tab key pressing when the Batch Edit mode is used

$
0
0

UPDATED:

Starting with version v2016 vol 1 (v16.1), a similar functionality is available out of the box. Set the grid's SettingsEditing.BatchEditSettings.StartEditAction property to the FocusedCellClick value to activate it. Please refer to the Batch Editing and Updating demo and ASPxGridView - Batch Edit - Provide cell focusing and keyboard navigation thread for more information.

If you have version v16.1+ available, consider using the built-in functionality instead of the approach detailed below.

For earlier versions: 

This example demonstrates how to change the order of focusing ASPxGridView cells by pressing the Tab key when the Batch Edit mode is used.

In this example, the ASPxClientUtils.AttachEventToElement method allows defining a handler for the keydown event of ASPxGridView's main element. The ASPxClientGridViewBatchEditApi.StartEdit method is used for changing the order of cell focusing. A list of read-only column indexes is stored in ASPxGridView.JSProperties.

Question Comments

Added By: Marc Michaels at: 11/17/2017 12:34:37 PM    I do not believe this is obsolete at all.  When you have a banded grid in batch edit mode, you CAN NOT press the tab key and move focus the the column beneath it.  The tab key only moves to the next cell horizontally. Once you tab through all of the top band, then focus goes to the bottom band.

You end up having to do something ridiculous like this (which doesn't work if columns are moved around):

        function OnInit(s, e) {
            ASPxClientUtils.AttachEventToElement(s.GetMainElement(), "keydown", function (evt) {
                if (evt.keyCode == 9 || evt.keyCode == 13) {
                    if (evt.shiftKey) {
                        ASPxClientUtils.PreventEventAndBubble(evt);
                        CustomMoveFocusBackwards();
                    }
                    else {
                        ASPxClientUtils.PreventEventAndBubble(evt);
                        CustomMoveFocus();
                    }
                }
            });
        }


        function CustomMoveFocus() {
            console.log(FocusedCellColumnIndex);
            if (FocusedCellColumnIndex == 34)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 30);
            else if (FocusedCellColumnIndex == 30)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 32);
            else if (FocusedCellColumnIndex == 33)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 28);
            else if (FocusedCellColumnIndex == 29)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 26);
            else if (FocusedCellColumnIndex == 27)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 24);
            else if (FocusedCellColumnIndex == 25)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 22);
            else if (FocusedCellColumnIndex == 23)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 21);
            else if (FocusedCellColumnIndex == 21)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 20);
            else if (FocusedCellColumnIndex == 20)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 17);
            else if (FocusedCellColumnIndex == 19)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 15);
            else if (FocusedCellColumnIndex == 16)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 13);
            else if (FocusedCellColumnIndex == 14)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 12);
            else if (FocusedCellColumnIndex == 12)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 34);
            else
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, FocusedCellColumnIndex + 1);
        }
        function CustomMoveFocusBackwards() {
            console.log(FocusedCellColumnIndex);
            if (FocusedCellColumnIndex == 30)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 34);
            else if (FocusedCellColumnIndex == 32)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 30);
            else if (FocusedCellColumnIndex == 28)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 33);
            else if (FocusedCellColumnIndex == 26)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 29);
            else if (FocusedCellColumnIndex == 24)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 27);
            else if (FocusedCellColumnIndex == 22)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 25);
            else if (FocusedCellColumnIndex == 21)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 23);
            else if (FocusedCellColumnIndex == 20)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 21);
            else if (FocusedCellColumnIndex == 17)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 20);
            else if (FocusedCellColumnIndex == 15)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 19);
            else if (FocusedCellColumnIndex == 13)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 16);
            else if (FocusedCellColumnIndex == 12)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 14);
            else if (FocusedCellColumnIndex == 34)
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, 12);
            else
                grdboard.batchEditApi.StartEdit(FocusedCellRowIndex, FocusedCellColumnIndex - 1);
        }


How to use the ASPxGridView control (with the enabled vertical scrollbar) in a Full Screen mode (100% browser Width and Height)

$
0
0

This example demonstrates how to resize the ASPxGridView control based on the browser window size.

Update:
To keep the visual grid's size intact while adjusting it on the first load, wrap ASPxGridView with a hidden container and show it only after its full initialization and adjustment. For example:

[ASPx]
<divid="gridContainer"style="visibility: hidden"><dx:ASPxGridViewrunat="server"ID="gridView"...> ...</dx:ASPxGridView></div>
[JavaScript]
function OnInit(s, e){ AdjustSize(); document.getElementById("gridContainer").style.visibility = "";}

See Also:

How to use the ASPxPageControl control in a Full Screen mode (100% browser Width and Height)

Question Comments

Added By: neuDev33 at: 5/16/2012 11:48:45 AM    

I'm copy + pasting this code, but the height does not increase to cover the parent control

Added By: just wqq at: 9/18/2012 7:45:13 PM    

DevExpress.Web.ASPxGridView.v8.3 can do this

Added By: Michelle Young at: 7/31/2013 7:46:42 AM    

Visual studio says the code behind method is obsolete and you should now use RegisterBaseScript instead.

Added By: Yevgeniy Reznik at: 7/31/2013 8:45:41 PM    

Can you please update to the latest version of DevExpress?

Added By: Honesto Manlig at: 5/28/2014 9:03:24 PM    

How can I have the columns to be of width they need to be. Except for the last column to be the only one that grows to fill the rest of the gridview. For example, if there's three columns, if first column contains  text, it'll get as wide as it needs to so it does not wrap the text, then second column is a checkbox, so can always be same width, then the last column must get wide enough so that it fills the rest of the grid's width.

Added By: Artem (DevExpress Support) at: 5/29/2014 12:01:42 AM    Hello,

I've moved your question to a separate thread created on your behalf:
How to use the ASPxGridView control (with the enabled vertical scrollbar) in a Full Screen mode (100% browser Width and Height)
Please refer to it for further correspondence.Added By: Satarupa Brahma 1 at: 3/8/2016 10:37:29 AM    It is important to note that the ClientInstanceName needs to be set so that the java script can find the control that needs to be resized.   I struggled with this for several hours before I found the key.Added By: Jonathan Kent at: 9/7/2017 5:05:55 AM    When trying to implement this resolution using Razor it worked fine but I experienced a javascript error when my gridview was editable when clicking on add or update. To resolve the issue I removed all javascript and simply added this line to my gridview implentation;
settings.ClientSideEvents.Init = "function OnInit(s, e) {myGridViewName.SetHeight(Math.max(0, document.documentElement.clientHeight));}";
Added By: Larry (DevExpress Support) at: 9/7/2017 5:28:31 AM    

Hello Jonathan,

Thank you for providing your solution. I believe it may be helpful to other users.

Added By: Patrik Johansson _ at: 11/18/2017 9:05:40 AM    This ticket claims to set widht and height but I can see no code that actually sets the width? Also, I still find it strange that such an obvious feature as to resize the popup window for a very mature control like the ASPxGridView should require this much manual coding even in 2017. 

dxDataGrid - How to use dxDropDownBox as a column editor in edit mode

$
0
0

This example illustrates how to use dxDropDownBox with an embedded dxDataGrid for editing data. Run the example and check the State column to see this approach in action.

Click the "Show Implementation Details" link to see step-by-step instructions.

Question Comments

Added By: Johseffer Wellynton Chepli at: 11/20/2017 2:31:06 AM    Can u send me this approach on angular, with this column directly in the template without jquery?

ASPxCardView - How to upload files in the Edit mode and save them in a database

$
0
0

This example demonstrates how to upload and save files in the Edit mode.
ASPxUploadControl in EditItemTemplate is used to upload files. A file is saved to a session in the ASPxUploadControl.FileUploadComplete event handler.

Then the uploaded file is saved to a database in the ASPxCardView.CardUpdating event handler when the user saves changes.
To provide the user with a capability to download files the ASPxHyperLink control is used in DataItemTemplate. The ASPxHyperLink.Text and ASPxHyperLink.NavigateUrl properties are set in the ASPxHyperLink.Load event handler using the technique described in the The general technique of using the Init/Load event handler topic.


How to customize the Appointment Dialog using View Model API

$
0
0

Example

View Model API enables you to customize dialog element characteristics (values, availability, and a layout) as needed, without the necessity of overriding ASPxScheduler's commands and copying dialog form templates (UserControls) into your project.

This example illustrates how to customize the Appointment Dialog content (changing the editor's type, visibility, captions, and font settings) using Model View API as described in the How to customize Appointment Dialog using View Model API topic. 

Master-Detail Pattern - MVVM

$
0
0
This example illustrates how to create a basic application that uses the Master-Detail Pattern based on the MVVM design pattern.

How to: Use Google, Facebook and Microsoft accounts in ASP.NET XAF applications (OAuth2 authentication demo)

$
0
0
This example demonstrates the use of OAuth2 authentication in a web application. Users can sign in to the application via Google, Facebook or  Microsoft authentication providers.


You can try this demo "as is" to overview its capabilities, and then try the demonstrated functionality in your own XAF applications according to the instructions below.


How to Run this Demo

Before running this demo, register developer accounts at the services you are going to use:
https://console.developers.google.com/
https://developers.facebook.com/
https://apps.dev.microsoft.com/ 

Open the Web.config file and specify your own client IDs and client secrets for each provider.

[XML]
<appSettings><addkey="GoogleClientID"value="YourGoogleClientID"/><addkey="GoogleClientSecret"value="YourGoogleClientSecret"/><addkey="FacebookClientID"value="YourFacebookClientID"/><addkey="FacebookClientSecret"value="YourFacebookClientSecret"/><addkey="MicrosoftClientID"value="YourMicrosoftClientID"/><addkey="MicrosoftClientSecret"value="YourMicrosoftClientSecret"/>

You can remove keys corresponding to providers that you do not want to use. 


Now you can run the application.


Overview of this Demo Capabilities


In the logon window, there are buttons for each provider specified in Web.config:


Standard XAF authentication with built-in username/password is also supported. When you log in via OAuth authentication, the email is used as a user name. By default, a user object is autocreated for each logon. You can disable autocreation, or specify the auto-assigned role for new users in the InitializeComponent method (see WebApplication.cs(vb)):
[C#]
this.securityStrategyComplex1.NewUserRoleName="Default";((AuthenticationStandartWithOAuth)authenticationBase).CreateUserAutomatically=true;
[VB.NET]
Me.securityStrategyComplex1.NewUserRoleName = "Default"CType(authenticationBase, AuthenticationStandartWithOAuth).CreateUserAutomatically = True
When CreateUserAutomatically is false, the logon is allowed if a user with the email returned by the external service exists in the application database. To grant access to a user with a specific e-mail, use the built-in Admin account, create a user object and set the UserName to this e-mail.



If you set the EnableStandardAuthentication property to true for an auto-created user, this user will be able to login directly, with a user name and password. Note that the password is empty by default, so do not forget to specify it when enabling standard authentication.



Each user can have several associated email addresses. To add or remove email addresses, use the  OAuth Authorization Emails list in the user's Detail View.



How to Implement the Demonstrated Functionality in your XAF Application
 

1. In your solution, open Package Manager Console.
  1.1. Choose the YourSolutionName.Web project in the Default project combo box, and execute the following commands to add Owin packages:
  Install-Package Microsoft.Owin -Version 3.1.0
  Install-Package Microsoft.Owin.Security -Version 3.1.0
  Install-Package Microsoft.Owin.Security.Cookies -Version 3.1.0
  Install-Package Microsoft.Owin.Host.SystemWeb -Version 3.1.0
  Install-Package Microsoft.Owin.Security.Google -Version 3.1.0
  Install-Package Microsoft.Owin.Security.Facebook -Version 3.1.0
  Install-Package Microsoft.Owin.Security.MicrosoftAccount -Version 3.1.0
  1.2. Switch to the YourSolutionName.Module.Web project and install these two packages:
  Install-Package Microsoft.Owin -Version 3.1.0
  Install-Package Microsoft.Owin.Host.SystemWeb -Version 3.1.0

2. Open the Web.config file and specify your own client IDs and client secrets for each provider you are going to use. Refer to the AuthenticationOwin.Web\Web.config file in the demo solution to see the example. Then, set the authentication mode to "None" and comment or remove settings related to the default XAF authentication:
[XML]
<authenticationmode="None"/><!--<forms name="Login" loginUrl="Login.aspx" path="/" timeout="10" />--></authentication><!--<authorization><deny users="?" /><allow users="*" /></authorization>-->

3. Copy the following files from the demo solution to the corresponding locations within your solution:
- AuthenticationOwin.Module\AuthenticationStandartWithOAuth.cs(vb)
- AuthenticationOwin.Module\IAuthenticationOAuthUser.cs(vb)
- AuthenticationOwin.Module.Web\Controllers\LogonAuthController.cs(vb)
- AuthenticationOwin.Module.Web\Security\CustomSecurityStrategyComplex.cs(vb)
- AuthenticationOwin.Module.Web\Controllers\LogonAuthController.cs(vb)
- AuthenticationOwin.Module.Web\Images\Facebook.svg
- AuthenticationOwin.Module.Web\Images\Google.svg
- AuthenticationOwin.Module.Web\Images\Microsoft.png

- AuthenticationOwin.Web\Startup.cs(vb)
AuthenticationOwin.Web\LogonTemplateContent1.ascx
AuthenticationOwin.Web\LogonTemplateContent1.ascx.cs(vb)
AuthenticationOwin.Web\LogonTemplateContent1.ascx.designer.cs(vb)
Include the copied files to your solution (Add | Existing Item...). Update the namespace names in the copied code files to match namespaces you use in your solution. For image files, set the Build Action property to Embedded Resource.

4. Edit the YourSolutionName.Module\Module.cs file. In the overridden Setup method, handle the XafApplication.CreateCustomLogonWindowControllers event and add the LogonAuthController to the e.Controllers collection passed to this event. Refer to the AuthenticationOwin.Module.Web\Module.cs(vb) file to see an example.

5. Edit the YourSolutionName.Web\WebApplication.cs(vb) code and register this custom security strategy:
[C#]
this.securityStrategyComplex1=newAuthenticationOwin.Module.Web.Security.CustomSecurityStrategyComplex();
[VB.NET]
Me.securityStrategyComplex1 = New AuthenticationOwin.Module.Web.Security.CustomSecurityStrategyComplex()

6. Implement the IAuthenticationOAuthUser interface in your custom user class. You can see an example in the AuthenticationOwin.Module\BusinessObjects\OAuthUser.cs file. If you use the built-in user, you can copy the OAuthUser class to your project from the demo and set the SecurityStrategy.UserType property to OAuthUser in the Application Designer.

7. Change the code that creates your predefined users in YourSolutionName.Module\DatabaseUpdate\Updater.cs. Set EnableStandardAuthentication to true for users who can login with standard authentication (username and password). See the example in the AuthenticationOwin.Module\DatabaseUpdate\Updater.cs file.

8. Register the LogonTemplateContent1.ascx template in the YourSolutionName.Web\Global.asax.cs file:
[C#]
WebApplication.Instance.Settings.LogonTemplateContentPath="LogonTemplateContent1.ascx";
[VB.NET]
WebApplication.Instance.Settings.LogonTemplateContentPath = "LogonTemplateContent1.ascx"

9. Copy the LoginWith* actions customizations and the AuthenticationStandardLogonParameters_DetailView layout settings from the AuthenticationOwin.Module.Web\Model.xafml file to the same file in the YourSolutionName.Web project. If you have no model customizations in Model.xafml, you can just overwrite it with the file from demo. Ensure that the IsPostBackRequired property of each LoginWith* action is set to true.


Tip: You can refer to the OWIN OAuth 2.0 Authorization Server documentation to learn how to add more authentication providers.

For an example of integrating OAuth2 authentication in a WinForms XAF application, refer to the XAF - OAuth2 Authentication for WinForms ticket.

Question Comments

Added By: Scott Gross at: 7/14/2017 8:43:09 AM    Will this work with XAF Mobile as well?Added By: Konstantin B (DevExpress) at: 7/16/2017 11:07:04 PM    We haven't yet tested this approach with XAF Mobile. However, we will consider including the mobile app project to this demo. I've created a separate ticket on your behalf (T536304: OAuth2 authentication in XAF Mobile). It has been placed in our processing queue and will be answered shortly.Added By: Rik Pronk at: 8/1/2017 6:41:49 AM    In the sample project, I noticed some errors in the web.config file. Below 'For applications with a security system' the <Authentication> tag is used, but that's supposed to be the <authorization> tag instead.Added By: Konstantin B (DevExpress) at: 8/1/2017 8:49:03 AM    Hello Rik,

Your comment is correct, we have updated this demo. Thanks!  Added By: Martin Svärd at: 8/31/2017 3:40:34 AM    Hi Konstantin,

I am not able to try this example, even though I register it with Microsoft.
Am I missing something?
And will this work with Microsoft Azure as well, or is it only Microsofts non O365 accounts? Added By: Dennis (DevExpress Support) at: 8/31/2017 3:55:20 AM    @Martin: Thanks for your interest. I've created a separate ticket on your behalf (T550911: Difficulties when running the T535280 example (OAuth2 authentication)). It has been placed in our processing queue and will be answered shortly.Added By: Genesis Supsup 1 at: 10/23/2017 8:56:59 PM    Is it possible to implement this in XAF using Windows Forms?Added By: Dennis (DevExpress Support) at: 10/24/2017 12:02:24 AM    @Genesis Supsup: We will answer you in the XAF - OAuth2 Authentication for WinForms ticket. Thanks.

How to use Reporting Controls in ASP.NET Core applications

How to load a VCard file and represent it in XtraReport as QR code

$
0
0

This example illustrates how to load *.vcf files and render them in XtraReport in QR code.

Question Comments

Added By: Chris W. at: 11/20/2017 11:40:53 PM    I tried this example, but unfortunately it doesn't work. I can choose the vcard, the report is displayed, but it is shown with a big red X across the whole page.

How to manage users (register a new user, restore a password, etc.) from the logon form in ASP.NET

$
0
0

We'd like to announce that we've published an example demonstrating an alternative and more recommended solution to managing user authentication, registration and related tasks:
How to: Use Google, Facebook and Microsoft accounts in ASP.NET XAF applications (OAuth2 authentication demo)

Instead of creating and maintaining a quite complex custom-tailored implementation for managing users from the logon form, we recommend delegating these routine tasks to OAuth2 providers. For instance, Microsoft or Google provide Office 365 and G Suite services for managing users (e.g., register and delete users, reset forgotten passwords), documents, apps and other things within an organization using standard and familiar for business people means. Your XAF application will just smoothly integrate these OAuth2 providers into the logon form after adding some boilerplate code.

Your feedback on this implementation and the approach in general is welcome.
====================
Scenario

This example contains a reusable Security.Extensions module that provides a possible solution for the following scenarios:

Security - provide the capability to register a new user from the logon form
Security.Authentication - provide a "Forgot Password" feature


Steps to implement

In order to use this module in your project, do the following:

1. Download and include the Security.Extensions module project into your XAF solution (as per MSDN) and rebuild it. This custom module contains Application Model settings (Model.DesignedDiffs.xafml) to layout custom Actions next to the logon form input fields (see the How to: Include an Action to a Detail View Layout  article for more details) as well as non-persistent data models for parameter screens (LogonActionParameters.cs) and finally a ViewController (ManageUsersOnLogonController.cs) for the logon DetailView that declares custom Actions and their behavior. The controller is registered via the XafApplication.CreateCustomLogonWindowControllers event in the ModuleBase descendant (Module.cs) along with other service logic.

2. Invoke the Module Designer for your platform-agnostic module and drag and drop the SecurityExtensionsModule from the Toolbox;

3. Add the following code into your platform-agnostic module class:

[C#]
staticYourPlatformAgnosticModuleName(){SecurityExtensionsModule.CreateSecuritySystemUser=Updater.CreateUser;}

where 'Updater.CreateUser' is your custom method that matches the following definition:

[C#]
publicdelegateIAuthenticationStandardUserCreateSecuritySystemUser(IObjectSpaceobjectSpace,stringuserName,stringemail,stringpassword,boolisAdministrator);

 

IMPORTANT NOTE
This module is currently ASP.NET only.

Question Comments

Added By: Daniele Bonetti at: 8/27/2012 3:14:19 PM    

downloaded and run the demo but i receive "Object reference not set to an instance of an object" error
xaf 12.1.5

Added By: octavia at: 9/24/2012 12:03:14 AM    

It can't be run. Object reference not set to an instance of an object" error

Added By: Santiago Moscoso at: 11/12/2012 3:39:21 PM    

On windows needs to invoke "EnsureShowViewStrategy" method from application, it's protected so you must use reflection.

On web I have problems with the action buttons not refreshing properly, must presh F5 to update buttons. (I'm working on 11.2.11)

Added By: Evgeniy Meyke at: 11/26/2012 4:59:41 AM    

Dennis, any chance to have this checked out soon?

   //Dennis: TODO
            //A possible issue in the framework - Controllers from ShowViewParameters are not added to the current Frame on the Web.
            //e.ShowViewParameters.Controllers.Add(CreateDialogController());

Added By: drew.. at: 3/9/2013 1:16:29 PM    

quick question before i begin integrating this: referring to the comment above " Include the module sources into your solution and rebuild it;" .. are you referring to the modules as listed below, or ALL the xaf modules?

Added By: drew.. at: 3/11/2013 10:12:45 AM    

.. for the benefit of others, this reference to "module" in #1 above, means to drop the entire Security.Extensions folder from the demo into your current solution that you want to update with the basic feature. Then add a reference from your platform-agnostic module (PAM) to the added project, rebuild, THEN go into the module designer for the PAM and drag-n-drop your newly added security module into the required modules section. Then rebuild again.

Added By: drew.. at: 3/11/2013 10:31:40 AM    

btw, i am in the process of integrating this with my DC-only based project. Once i have all the conversions done and tested i will likely post the project to help others save time.

Added By: Mario Blatarić at: 3/12/2013 1:59:10 AM    

Which parts make this module ASP.NET only? I don't understand what needs to be changed in order to make this work in WinForms as well. Any hints?

Added By: John01 at: 4/16/2013 8:10:38 AM    

Hi

When I run the example and click OK on register user I get the error 'Property 'Email' does not exist within type 'DevExpress.ExpressApp.Security.Strategy.SecuritySystemUser'.' on line user.SetMemberValue("Email", email) in function CreateUser. The email value is 'sam@example.com'. I did upgrade the project to 12.2.7 before running though. Any ideas?

Thanks

Regards

Added By: CArlos segura_1 at: 6/13/2013 1:22:53 PM    

someone has been to implement this?

Added By: Tony Tadros Zaky at: 9/5/2013 11:51:37 PM    

Hello Devexpress ,

having problem for some time downloading your examples
was thinking something wrong with my pc but tried some other still the same thing

ICAP Error (icap_error)

  
 An error occurred while performing an ICAP operation: Maximum file size exceeded; File: GetExample; Sub File: ManageUsersOnLogon.Module\BusinessObjects\ReadMe.txt; Vendor: Kaspersky Labs; Engine error code: 0x00000000; Engine version: 8.1.8.79; Pattern version: 130905.225000.10967985; Pattern date: 2013.09.05 22:50:00
 There could be a network problem, the ICAP service may be misconfigured, or the ICAP server may have reported an error.

 For assistance, contact your network support team.

Added By: Apostolis Bekiaris (DevExpress) at: 9/19/2013 3:35:30 AM    

Implemented in eXpandFramework 13.1.7.1
http://apobekiaris.blogspot.gr/2013/09/how-to-manage-users-register-new-user.html

Added By: Daniele M at: 7/26/2015 3:21:28 AM    

I would like to add a capctha code in this registration page.
how can i do? is there an example?
thanks

Added By: Dennis (DevExpress Support) at: 7/27/2015 2:46:05 AM    

@Daniele: While we do not have a ready E4037 example modification for this particular scenario, you can find the following ASP.NET documentation and reference tickets helpful:
ASPxCaptcha Overview
How to Validate a Captcha On Logon Screen
ASPxCaptcha in login page
How to: Use Custom Logon Parameters and Authentication

Should you experience any implementation difficulties, submit a separate ticket and attach your test project showing what you tried to implement according to this information.Added By: Daniele M at: 9/7/2015 7:31:28 AM    

is it possible to customize the logon form in order to obtain the logon button first of two rows with the button "forgot password" and "create a new user"?

Added By: Daniele M at: 9/7/2015 9:04:38 AM    

is it possible to change label to user name in register user form? I tried with displayname attribute in RegisterUserParameters,cs but it didn't work.
thanks

Added By: Dennis (DevExpress Support) at: 9/8/2015 2:43:16 AM    

@Daniele:
Both things are possible. The Security.Extensions module contains the Model.DesignedDiffs.xafml file with model customizations of the AuthenticationStandardLogonParameters_DetailView node. This node determines what your logon form will look like in the UI. You can customize its layout or change captions of items via the Model Editor designer. Should you experience any further customization difficulties here, please submit a separate ticket, and describe what you tried to do and what did not work as expected. Thanks.

Added By: Daniele M at: 9/25/2015 1:12:51 AM    

I can not integrate the example 3 with https://www.devexpress.com/Support/Center/Example/Details/E2849 to enforce password complexity.
can you help me?
thank you

Added By: Anatol (DevExpress Support) at: 9/25/2015 2:23:18 AM    

Hello Daniele,

To process your recent post more efficiently, I created a separate ticket on your behalf: T293660: How to integrate the E4037 and E2849 examples. This ticket is currently in our processing queue. Our team will address it as soon as we have any updates.

Added By: MohammedFarooq at: 10/9/2015 5:33:10 PM    

Hi Dennis & Anatol,

I have used the is example in my project and it works great.

could you please show how to add an image (mylogo.png for example) on the right top corner of the logon page? It is a png image to show company's logo on the logon page.

Added By: Dennis (DevExpress Support) at: 10/12/2015 3:58:10 AM    @MohammedFarooq:
I am happy to hear of your progress.
>> how to add an image (mylogo.png for example) on the right top corner of the logon page?

Would you please submit a separate ticket and attach a screenshot of the desired UI, because possible solutions will vary a lot based on the exact logo placement?

Added By: MohammedFarooq at: 10/12/2015 8:54:03 AM    

Hi Dennis,

I have created a separate ticket as suggested by you.

https://www.devexpress.com/Support/Center/Question/Details/T299424

Added By: Vishwas Mokashi at: 12/24/2015 3:42:16 AM    

Hello,

I want to implement User Registration in our solution.

<<

Steps to implement
In order to use this module in your project, do the following:
1. Include the module sources into your solution and rebuild it;
>>

What are Module Sources ?  Module.cs?  LogonActionParameters.cs?, ManageUsersOnLogonController.cs? given in this ticket?
where and how to include it in solution?

Added By: Dennis (DevExpress Support) at: 12/24/2015 4:50:41 AM    @Vishwas: I have updated this instruction. Let me know in case of any further questions.Added By: Vishwas Mokashi at: 12/24/2015 6:21:21 AM    

Dennis, thanks I know how to include project but where from to down load?. Or I create new Module project and copy paste the code classes given in this ticket?

Added By: Dennis (DevExpress Support) at: 12/24/2015 6:31:24 AM    

@Vishwas: You can download complete example source code under the Downloads section at the right side of the example webpage. Let me know if you experience any further difficulties here.

Added By: Vishwas Mokashi at: 12/24/2015 6:36:55 AM    

Thanks Dennis, I had done that but problem was I did not have the Sample Runner loaded on my machine and could not extract the files.

Thank you and Merry Christmas!!

Added By: Dennis (DevExpress Support) at: 12/24/2015 7:02:23 AM    @Vishwas: Am I correct that you have now installed the Example Runner and could download this example? If so,  I am happy to hear of your results.
Merry Xmas to you and yours too!Added By: Vishwas Mokashi at: 12/24/2015 7:14:39 AM    

Yes Dennis, I have Sample Runner, could download it and use it also. Thanks...

Added By: Dennis (DevExpress Support) at: 12/24/2015 7:33:15 AM    @@Vishwas: Great!Added By: Ryan Elliott_ at: 5/23/2016 12:31:49 PM    where do I find the Security.Extensions module project?Added By: Dennis (DevExpress Support) at: 5/23/2016 12:35:54 PM    @Ryan: See the download link under the Downloads section on the right side of the example's page.Added By: Ryan Elliott_ at: 5/24/2016 7:45:41 AM    @Dennis - Thanks, I got it downloaded and added to our project.  But we don't have a createUser, all of our user accounts will be created by an Admin on a need basis.  is there anyway to use just the Forgot Password functionality?Added By: Dennis (DevExpress Support) at: 5/24/2016 8:00:40 AM    

@Ryan: Thanks for informing me of your results. Sure, you can modify the downloaded project code and remove anything that you do not need from it (e.g. get started with the ManageUsersOnLogonController class). After all, it is just a Controller with custom Actions and related code/XAFML.

Added By: Ryan Elliott_ at: 5/24/2016 8:23:41 AM    @Dennis - I've commented out the RegisterUserAction code in ManageUsersOnLogonController.cs.  My main issue now is with the Module.cs class, and the lines of code below:

static ModuleNameGoesHere()
{
     SecurityExtensionsModule.CreateSecuritySystemUser = Updater.CreateUser;
}

I get an error for "'Updater' does not contain a definition for 'CreateUser'"  Added By: Dennis (DevExpress Support) at: 5/24/2016 8:24:27 AM    @Ryan: These lines are related to the "register new users" functionality and you can comment them out.Added By: Ryan Elliott_ at: 5/24/2016 9:02:03 AM    @Dennis - I've got those lines removed, but now since I've added the SecurityExtensionsModule to the Module.cs of our Module project, I get the below error in Global.asap.cs - WebApplication.Instance.Start();

An exception of type 'DevExpress.ExpressApp.Model.Core.DuplicateModelNodeIdException' occurred in DevExpress.ExpressApp.v15.2.dll but was not handled in user code


Additional information: There is already node with Id 'RestorePassword'. The node: Application/ActionDesign/Actions/RestorePassword.
Added By: Dennis (DevExpress Support) at: 5/25/2016 1:32:32 AM    

@Ryan: This exception indicates that you have included the Controller with RestorePassword Action twice into your application by a mistake. I guess once into YourSolutionName.Module and once as part of the Security.Extensions module. It is correct to include this functionality only once: either as a part of the Security.Extentions module, whose code you are free to modify, or as a part of your own module. So, remove the duplication and everything will go back to normal. If this does not help, please submit a separate ticket via the https://www.devexpress.com/Support/Center/Question/Create service and attach your problematic sample there.

Added By: Ryan Elliott_ at: 5/25/2016 12:05:18 PM    @Dennis - just created this ticket - https://www.devexpress.com/Support/Center/Question/Details/T383948Added By: MohammedFarooq at: 10/29/2016 11:47:20 AM    Hi Dennis,

Just a silly question, Can we show the RestorePassword or RgisterUser buttons as links instead of buttons?

Can ActionUrl object be used in this case? if yes, then can you please guide me on its usage. Added By: Dennis (DevExpress Support) at: 10/31/2016 5:41:17 AM    

@MohammedFarooq: I've created a separate ticket on your behalf (T445256: How to show the RestorePassword or RgisterUser buttons as links instead of buttons (extending E4037)). It has been placed in our processing queue and will be answered shortly.

Added By: Michael (DevExpress Support) at: 7/18/2017 7:46:13 AM    We'd like to announce that we've published an example demonstrating an alternative and more recommended solution to managing user authentication, registration and related tasks:
How to: Use Google, Facebook and Microsoft accounts in ASP.NET XAF applications (OAuth2 authentication demo)

Instead of creating and maintaining a quite complex custom-tailored implementation for managing users from the logon form, we recommend delegating these routine tasks to OAuth2 providers. For instance, Microsoft or Google provide Office 365 and G Suite services for managing users (e.g., register and delete users, reset forgotten passwords), documents, apps and other things within an organization using standard and familiar for business people means. Your XAF application will just smoothly integrate these OAuth2 providers into the logon form after adding some boilerplate code.

Your feedback on this implementation and the approach in general is welcome.

Added By: Michael (DevExpress Support) at: 11/21/2017 8:27:21 AM    We've created an additional example that demonstrates How to add OAuth2 authentication to a WinForms app. Your feedback is welcome.

How to reorder GridView rows using buttons or drag-and-drop

$
0
0
This example demonstrates how to move GridView rows using buttons or jQuery UI  Draggable and Droppable plug-ins. To keep the order of rows, it is necessary to set up an extra column to store row order indexes. Then, sort GridView by this column and deny sorting by other columns.

See also:
E4582 - How to reorder ASPxGridView rows using buttons or drag-and-drop
Question Comments

Added By: Nishant Jha 1 at: 6/14/2016 11:44:23 AM    Thanks for this example. It helped me a lot.Added By: Raphael A. at: 11/21/2017 10:10:38 AM    Droppable function is sensible, if you drag and drop a grid view row for one pixel, it will trigger gridview callback. To avoid this, I changed 
[ASPx]
vardraggingSortIndex=ui.draggable.attr("displayIndex");vartargetSortIndex=$(this).attr("displayIndex");gridView.PerformCallback({draggingIndex:draggingSortIndex,targetIndex:targetSortIndex,command:"DRAGROW"});
for this
[ASPx]
vardraggingSortIndex=ui.draggable.attr("displayIndex");vartargetSortIndex=$(this).attr("displayIndex");if(targetSortIndex!==draggingSortIndex){gridView.PerformCallback({draggingIndex:draggingSortIndex,targetIndex:targetSortIndex,command:"DRAGROW"});}


How to implement an unbound editable check column

$
0
0

This example demonstrates how to emulate row selection via an unbound column with a checkbox. The grid's built-in editing is used. It's enabled when the view's NavigationStyle property is set to CellNavigation.

Starting from the 12.1.8 version, we support a new way of implementing multiple row selection via a checked column. Please refer to the following article, which shows how to implement this: How to implement multiple row selection behavior via a checked column.

Question Comments

Added By: Praveen Kumar 54 at: 3/6/2013 3:11:53 AM    

I want to achieve the same functionality using MVVM pattern. Basically without writing any code in .Cs File. Does DevXpress support this ?

ASPxFileManager - How to implement a custom FileSystem provider and set required permissions to files or folders

$
0
0

This example demonstrates how to create a custom FileSystem provider and assign permissions to each folder or file. This example uses two tables.
The first one - FileSystemItems - contains all the files and folders.
The second one - PermissionsSet - contains all the permissions assigned to folders or files.
It is required only to create a custom FileSystem provider and additionally override the GetFilePermissions and GetFolderPermissions methods that are used to gather permissions.

See alsoASPxFileManager Permissions

How to implement a simple PDF viewer in web ASP.NET WebForms applications by using the Document Server functionality

$
0
0

This example demonstrates how to implement a custom web PDF viewer control by using the DevExpress Document Server functionality.


The main idea of this approach is to use the PdfDocumentProcessor class functionality to load the PDF document and convert its pages to images. Then, these images are rendered in the browser to display PDF document pages.


Important Note:

The Document Server product license is required for using this approach. Please refer to the Subscriptions page for more information.

See also:
How to implement a simple PDF viewer in ASP.NET MVC web application by using the Document Server functionality

Question Comments

Added By: BJ Knudson at: 8/10/2017 2:23:33 PM    Is there a way to implement this with scrolling pages, instead of the page index at the top?Added By: Vasily (DevExpress Support) at: 8/11/2017 4:54:42 AM    

Hi BJ Knudson,

I've created a separate ticket on your behalf for this question: T544849: PDF Viewer - How to display PDF pages whiting a scrollable container instead of using pager. This ticket has been placed in our processing queue and will be answered shortly.

(Obsolete) dxTreeList - How to implement recursive selection

ASPxMenu - How to bind menu items to plain data

$
0
0

This example demonstrates how to bind the ASPxMenu control to plain data stored in a DataTable. The CreateMenuRecursively method creates menu items recursively.
To build a hierarchical structure of items, create an extra column in your DataTable (for example, ParentID in this case) to keep the parent's ID column value.

Viewing all 7205 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>