Please help,
I've followed the instructions for creating a dotnetnuke compiled module, i've added 2 controls to the datalist itemtemplate a button and a textbox.
In design mode i 've changed the text in the text box to 'abc'.
When i compile dnn and import the control it looks fine, but the viewstate isn't being maintained,
if i change the text and press the button the text goes back to what is was in design mode. its as if the module is constantly being reset to defaults on every post.
Please tell me what i'm doing wrong.
Option Strict Off
'
' DotNetNuke® - http://www.dotnetnuke.com
' Copyright (c) 2002-2005
' by Perpetual Motion Interactive Systems Inc. ( http://www.perpetualmotion.ca )
'
' Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
' documentation files (the "Software"), to deal in the Software without restriction, including without limitation
' the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
' to permit persons to whom the Software is furnished to do so, subject to the following conditions:
'
' The above copyright notice and this permission notice shall be included in all copies or substantial portions
' of the Software.
'
' THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
' TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
' THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
' CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
' DEALINGS IN THE SOFTWARE.
'
Imports System.Web.UI
Imports System.Collections.Generic
Imports System.Reflection
Imports DotNetNuke
Imports DotNetNuke.Services.Exceptions
Imports DotNetNuke.Services.Localization
Namespace YourCompany.Modules.TBSMS
''' -----------------------------------------------------------------------------
''' <summary>
''' The ViewTBSMS class displays the content
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
Partial Class ViewTBSMS
Inherits Entities.Modules.PortalModuleBase
Implements Entities.Modules.IActionable
#Region "Event Handlers"
''' -----------------------------------------------------------------------------
''' <summary>
''' Page_Load runs when the control is loaded
''' </summary>
''' <remarks>
''' </remarks>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load, Me.Load
Try
Dim objTBSMSs As New TBSMSController
Dim colTBSMSs As List(Of TBSMSInfo)
' get the content from the TBSMS table
colTBSMSs = objTBSMSs.GetTBSMSs(ModuleId)
If colTBSMSs.Count = 0 Then
' add the content to the TBSMS table
Dim objTBSMS As TBSMSInfo = New TBSMSInfo
objTBSMS.ModuleId = ModuleId
objTBSMS.Content = Localization.GetString("DefaultContent", LocalResourceFile)
objTBSMS.CreatedByUser = Me.UserId
objTBSMSs.AddTBSMS(objTBSMS)
' get the content from the TBSMS table
colTBSMSs = objTBSMSs.GetTBSMSs(ModuleId)
End If
' bind the content to the repeater
lstContent.DataSource = colTBSMSs
lstContent.DataBind()
Catch exc As Exception 'Module failed to load
ProcessModuleLoadException(Me, exc)
End Try
End Sub
Protected Sub lstContent_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles lstContent.ItemDataBound
Dim strContent As String = ""
' add content to template
If CType(Settings("template"), String) <> "" Then
strContent = CType(Settings("template"), String)
Dim objProperties As ArrayList = Common.Utilities.CBO.GetPropertyInfo(GetType(TBSMSInfo))
Dim intProperty As Integer
Dim objPropertyInfo As PropertyInfo
For intProperty = 0 To objProperties.Count - 1
objPropertyInfo = CType(objProperties(intProperty), PropertyInfo)
strContent = strContent.Replace("[" & objPropertyInfo.Name.ToUpper & "]", DataBinder.Eval(e.Item.DataItem, objPropertyInfo.Name).ToString())
Next intProperty
Else
strContent = DataBinder.Eval(e.Item.DataItem, "Content")
End If
' assign the content
Dim lblContent As Label = CType(e.Item.FindControl("lblContent"), Label)
lblContent.Text = strContent
End Sub
#End Region
#Region "Optional Interfaces"
''' -----------------------------------------------------------------------------
''' <summary>
''' Registers the module actions required for interfacing with the portal framework
''' </summary>
''' <value></value>
''' <returns></returns>
''' <remarks></remarks>
''' <history>
''' </history>
''' -----------------------------------------------------------------------------
Public ReadOnly Property ModuleActions() As Entities.Modules.Actions.ModuleActionCollection Implements Entities.Modules.IActionable.ModuleActions
Get
Dim Actions As New Entities.Modules.Actions.ModuleActionCollection
Actions.Add(GetNextActionID, Localization.GetString(Entities.Modules.Actions.ModuleActionType.AddContent, LocalResourceFile), Entities.Modules.Actions.ModuleActionType.AddContent, "", "", EditUrl(), False, Security.SecurityAccessLevel.Edit, True, False)
Return Actions
End Get
End Property
#End Region
End Class
End Namespace
<%@ Control language="vb" Inherits="YourCompany.Modules.TBSMS.ViewTBSMS" AutoEventWireup="false" Explicit="True" Codebehind="ViewTBSMS.ascx.vb" %>
<%@ Register TagPrefix="dnn" TagName="Audit" Src="~/controls/ModuleAuditControl.ascx" %>
<asp:datalist id="lstContent" datakeyfield="ItemID" runat="server" cellpadding="4"><ItemTemplate>
<TABLE cellPadding=4 width="100%"><TBODY><TR><TD vAlign=top align=left width="100%"><asp:HyperLink id="HyperLink1" runat="server" Visible="<%# IsEditable %>" NavigateUrl='<%# EditURL("ItemID",DataBinder.Eval(Container.DataItem,"ItemID")) %>'><asp:Image ID="Image1" Runat=server ImageUrl="~/images/edit.gif" AlternateText="Edit" Visible="<%#IsEditable%>" resourcekey="Edit"/></asp:HyperLink> <asp:Label id="lblContent" runat="server" CssClass="Normal"></asp:Label> </TD></TR></TBODY></TABLE>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:TextBox ID="TextBox1" runat="server">abc</asp:TextBox>
</ItemTemplate>
</asp:datalist>