Forum Topic(s) Update Problem

Topics: Help
May 5, 2009 at 1:18 AM
Has anyone else noticed that when trying to edit a forum topic, under the forum management section; that noting gets updated?  Try changing the Monitor to someone else or updating the check boxes, such as "locked".  Noting updates.

If so, does anyone have a fix for this yet?
Oct 21, 2009 at 11:32 PM

Yes, the Subroutine Page_Load in Manage.aspx is the problem.  When you first press the edit link it loads the page and fills in the values so you can edit them, however it also does this when you post your changes.  So the changes you make get set back to the original database setting before your new values get a chance to update.

In short, this page is the same page called to both intitated the edit (it fills in your input boxes for you to edit) and also the same page that your changes are posted to (but overwritten by the logic that fills in your input boxes in the first call).

Luckily it is easy enough to detect the difference between the two.  When clicking the 'edit' link, it is simply calling the page like a form get request would do.  When clicking the update button to save your changes it calls the page like a form post does (posting the changes).  So simply test Request.ContentLength and if it is zero, go ahead and let the original logic for the page happen, but if not do not let that logic overwrite your changes.  here is the updated Page_Load subroutine:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        If Request("editid") Is Nothing Then
            AddTopic.Visible = True
            UpdateTopic.Visible = False
            AddTopic.Visible = False
            UpdateTopic.Visible = True
            Dim topic As New Topics(Topics.Columns.Topicid, Request("editid"))
            If Request.ContentLength = 0 Then
                TopicName.Text = topic.Topic
                Description.Text = topic.Description
                SectionCHECK.Checked = topic.Section
                VisibleCHECK.Checked = topic.Visible
                LockedCHECK.Checked = topic.Locked
                Weight.Text = topic.Weight.ToString()
                DropDownList1.SelectedValue = topic.Moderatorkey.ToString()
            End If 
        End If
    End Sub