@Edit.Enable Method in C# Razor (Deprecated)
Editing or adding data to a 2sxc app requires the UI to have some JS, CSS and context information. This is only loaded/included for editors/admin/super-users, and not available for users with limited permissions.
If you want to enable this for more restricted users - for example when you want to use the 2sxc-form to let users add data - this must be enabled. That's what
Edit.Enable(...) is for.
Discover More in the Razor TutorialsWe have an rich series of Razor tutorials. You should really check them out 👍.
How to use
This example shows how you enable the UI using Razor, which will allow public users to create data:
<div> @Edit.Enable(api: true, forms: true, context: true, autoToolbar: false) </div>
This example ensures that
forms: additional JS is loaded, enabling the standard form dialogs to open
context: the html contains context-information about the app, so that the dialogs actually work - see also edit context
- the auto-toolbars are disabled (this would generate a default toolbar if no toolbar was specified)
This command simply enables editing - but doesn't provide any permissions or show any buttons yet. Here are a few things you must know to get this to work:
- remember to set permissions to allow what you want to do (like create new draft items for public users)
- Edit.Enable uses named parameters, so you always have to use the
- the Edit.Enable won't output anything in the position it's added, because it controls the main wrapper
- you must also create a link or toolbar in your code for the public users, as they won't have a button to press otherwise
- Introduced in 2sxc 9.30