943,958 Members | Top Members by Rank

Ad:
  • ASP.NET Discussion Thread
  • Unsolved
  • Views: 500
  • ASP.NET RSS
Apr 24th, 2009
0

CMS Webcontent based on ID

Expand Post »
I am trying to update web content on my site by the ID in the database. I am using a ASCX file in order to update the content and it's integrated with a BLL VB file. By example, the content on my Contact page needs to be updated, the DB table has the following columns: id, section (the section that is being updated, in this case "contactpage"), sectionContent, dateStmp and clubId.

I have set it up so that the section column's value can equal "contactpage" with different "clubId" values.

DB Example:

Section | SectionContent | clubId

contactpage | Call me now | NHSC
contactpage | Call me L8tr | ABC123
contactpage | Don't Call | KLM987
contactpage | Upchuck | CHUCK

When I go to update the page I want to grab the clubId=NHSC from the querystring, and update the relevant "sectionContent=Call Me now" column in the DB

Here is the BLL code that already exist, how can I modify it with a where statement club=@club from the querystring

ASP.NET Syntax (Toggle Plain Text)
  1. Public Class CMS
  2.  
  3. Public Shared Function GetContent(ByVal sectionname As String) As String
  4. Dim str As String = ""
  5. Dim qry As New Query(Tables.WebContent)
  6. qry.AddWhere(WebContent.Columns.Section, sectionname)
  7. If qry.GetRecordCount() = 1 Then
  8. Dim Content As New WebContent(WebContent.Columns.Section, LCase(sectionname))
  9.  
  10. If Content.IsLoaded Then
  11. str = Content.SectionContent.ToString()
  12. End If
  13. Else
  14. str = "IsNotAdded"
  15. End If
  16. Return str
  17. End Function


I am using FCKeditor, here is the code to update, I need to use the where statement to identify the clubId:

ASP.NET Syntax (Toggle Plain Text)
  1. Public Shared OrigionalContent As String = ""
  2. Public Shared IsNew as Boolean = False
  3.  
  4. Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
  5.  
  6. If Not Page.IsPostBack Then
  7. If Request("sectionname") Is Nothing Then
  8. Response.Redirect("~/default.aspx")
  9.  
  10. Else
  11. OrigionalContent = CMS.GetContent(Request.QueryString("sectionname").ToString())
  12. If OrigionalContent = "IsNotAdded" Then
  13. FCKeditor1.Value = "&lt;p&gt;</p>"
  14. IsNew = True
  15. Else
  16. FCKeditor1.Value = OrigionalContent
  17. IsNew = False
  18. End If
  19. End If
  20. End If
  21.  
  22. End Sub
  23.  
  24.  
  25. Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
  26. Dim newcontent As String = ""
  27. If FCKeditor1.Value = "" Then
  28. newcontent = "<p></p>"
  29. Else
  30. newcontent = FCKeditor1.Value
  31. End If
  32.  
  33. If OrigionalContent = "IsNotAdded" Or IsNew = True Then
  34. CMS.AddContent(Request.QueryString("sectionname").ToString(), newcontent)
  35. Else
  36. CMS.UpdateContent(Request.QueryString("sectionname").ToString(), newcontent)
  37. End If
  38.  
  39. Dim ip As String = Request.ServerVariables("REMOTE_ADDR")
  40.  
  41.  
  42. If Request("ReturnURL") Is Nothing = False Then
  43. Response.Redirect(CStr(Request("ReturnURL")))
  44. Else
  45. Response.Redirect("~/default.aspx")
  46. End If
  47.  
  48. End Sub

And of course the ASCX code that requires the Where clubId=@clubId statement


ASP.NET Syntax (Toggle Plain Text)
  1. Private _Section As String = ""
  2.  
  3. Public Property Section() As String
  4. Get
  5. Section = LCase(_Section)
  6. End Get
  7. Set(ByVal value As String)
  8. _Section = LCase(value)
  9. End Set
  10. End Property
  11.  
  12. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
  13. If Section Is Nothing Then
  14. Label_Content.Text = "Please enter a section name into the WebContent control."
  15. Else
  16. Try
  17. sectionnameprop.Value = _Section
  18. Label_Content.Text = ClubStarterKit.Web.CMS.GetContent(_Section)
  19. Catch ex As Exception
  20.  
  21. End Try
  22. Edit.Visible = Page.User.IsInRole("Editors")
  23.  
  24. 'Added this to get the querystring
  25. Dim clubId As String = Request.QueryString("clubId")
  26.  
  27. Dim url As String = "~\WebContent\Editor.aspx?sectionname=" & sectionnameprop.Value
  28. 'and this
  29. url += "&clubId=" & clubId
  30. url += "&ReturnURL="
  31. url += System.Web.HttpUtility.UrlEncode(Request.Url.ToString())
  32. Edit.NavigateUrl = url
  33. End If
  34. End Sub


Thanks everyone, please bare with me as I am new to the asp.net world.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dude9er is offline Offline
2 posts
since Jun 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ASP.NET Forum Timeline: First 4 cases Skipped by if statements
Next Thread in ASP.NET Forum Timeline: Help with Dictionary c#





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC