It's easy to use the DNNLabelEdit control, you know the one you mouse over and edit in place? Yeah, that one. In just a few minutes, you can begin using the control on your sites as well for full on the spot editing. Here's how:
Register the control
<%@ Register TagPrefix="dnn" Namespace="DotNetNuke.UI.WebControls" Assembly="DotNetNuke" %>
Apply Control to the Page
<dnn:DNNLabelEdit ID="lblContent" runat="server" LostFocusSave="False" ToolBarId="tbEIPHTML" MouseOverCssClass="LabelEditOverClassML"
RenderAsDiv="True" LabelEditCssClass="LabelEditTextClass" EnableViewState="False" Text="Click To Edit" />
*You don't have to use all of the properties, and there are actually many more than what is shown here.
Hook Up Your Update Method
Select the control and right click or hit F4 to get the properties in Visual Studio. Click on the lightning bolt to get to the methods. Type a name for your new update method and add it to the "UpdateLabel" field. Once you have entered the new name for the method, you will be sent to the code behind and will see the outline of the update method. From here you can add whatever logic you need. Basically, you can access the updated text with "e.Text.ToString" from within the newly create procedure, as seen below
Persisting the Update to a Database
Protected Sub AddNewCategory(ByVal source As Object, ByVal e As DotNetNuke.UI.WebControls.DNNLabelEditEventArgs) Handles lblContent.UpdateLabel
'create the object
Dim catInfo As New CategoriesInfo
'get the current user info
Dim user As UserInfo = UserController.GetCurrentUserInfo
'fill the object and
'assign the new text to the categoryName value
catInfo.CategoryName = e.Text.ToString
catInfo.CreatedBy = user.DisplayName
catInfo.CreatedOn = Date.Today
'update the catInfo object & persist to database
CatController.Create(catInfo)
End Sub