Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Viewstate Help!Viewstate Help!
Previous
 
Next
New Post
6/16/2008 1:10 PM
 

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>&nbsp;&nbsp;

 
New Post
6/17/2008 11:21 AM
 

In your page load you need a check for

NOT IsPostback

THen ONLY execute the databinding if it evaluates to try, as you have it now every load and postback will re-bind the grid, loosing any edits.


-Mitchel Sellers
Microsoft MVP, ASPInsider, DNN MVP
CEO/Director of Development - IowaComputerGurus Inc.
LinkedIn Profile

Visit mitchelsellers.com for my mostly DNN Blog and support forum.

Visit IowaComputerGurus.com for free DNN Modules, DNN Performance Tips, DNN Consulting Quotes, and DNN Technical Support Services
 
New Post
6/18/2008 3:47 AM
 

thanks for this, in the end i just removed the whole control and all the code that came with the template and it now works fine, just like a normal asp.net page would.

 

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Viewstate Help!Viewstate Help!


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out