-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEdit.ascx.cs
More file actions
62 lines (58 loc) · 2.36 KB
/
Edit.ascx.cs
File metadata and controls
62 lines (58 loc) · 2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using DotNetNuke.Entities.Users;
using DotNetNuke.Services.Exceptions;
using System;
using ToSic.Modules.ContentWorkflowDNNModule.Components;
namespace ToSic.Modules.ContentWorkflowDNNModule
{
/// -----------------------------------------------------------------------------
/// <summary>
/// The Edit class is used to manage content
///
/// Typically your edit control would be used to create new content, or edit existing content within your module.
/// The ControlKey for this control is "Edit", and is defined in the manifest (.dnn) file.
///
/// Because the control inherits from ContentWorkflowDNNModuleModuleBase you have access to any custom properties
/// defined there, as well as properties from DNN such as PortalId, ModuleId, TabId, UserId and many more.
///
/// </summary>
/// -----------------------------------------------------------------------------
public partial class Edit : ContentWorkflowDNNModuleModuleBase
{
protected void Page_Load(object sender, EventArgs e)
{
try
{
//Implement your edit logic for your module
if (!Page.IsPostBack)
{
var controller = new VersionableController();
var contentItem = controller.GetItem(ModuleId);
txtDescription.Text = contentItem?.Content;
}
}
catch (Exception exc) //Module failed to load
{
Exceptions.ProcessModuleLoadException(this, exc);
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
var controller = new VersionableController();
var contentItem = controller.GetItem(ModuleId);
if (contentItem == null || contentItem.IsPublished())
{
controller.CreateItem(ModuleConfiguration, txtDescription.Text.Trim());
}
else
{
contentItem.Content = txtDescription.Text.Trim();
controller.UpdateItem(ModuleConfiguration, contentItem);
}
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
}
protected void btnCancel_Click(object sender, EventArgs e)
{
Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
}
}
}