Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6
This is the forum to discuss the Wrox book ASP.NET 2.0 Instant Results by Imar Spaanjaars, Paul Wilton, Shawn Livermore; ISBN: 9780471749516
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET 2.0 Instant Results ISBN: 978-0-471-74951-6 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old April 8th, 2007, 01:19 PM
Authorized User
 
Join Date: Apr 2006
Location: , , USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chapter 5 CMS extension

I am about to start extending the CMS to include a comments. That is, I want readers to be able to comment on articles.
Any ideas on how to get started?
Any ideas on what pages to extend to accomplish this?
Cheers,
yousaid

  #2 (permalink)  
Old April 8th, 2007, 01:45 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

Hi yousaid,

No need to post alerts on my web site. I keep track of this forum here at wrox.com.

To create a comment feature, here's what I would do:

1. Create two user controls: CommentEntry and CommentList

2. On Entry, add controls for the comment like a Name and a Comment box. Give the page a ContentId property to track for which content item the comment is supposed to be,

3. When the user adds a comment, save it in the database and redirect to the current page.

4. Let CommentList display a list of comments in a repeater. Give it a CommentId as well so you know what comments to load.

5. Modify the content detail page: add a CommentEntry and a CommentList control. Assign their ContentId properties through code.

Take a look at the Blog chapter, as it implements some of these ideas.

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #3 (permalink)  
Old April 8th, 2007, 03:39 PM
Authorized User
 
Join Date: Apr 2006
Location: , , USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks,
I started out by following the instructions for extending the Blog.
I then created table and used the PK of the contents table as the foreign key of the new table.
My plan was to insert contentid into this table by passing the Id in a querystring, but that's not working.
Any ideas on how I can use Querystrings to pass the Id of the article on insert?
Assume I have this table:
comentid.......PK Not Null
contentId .....Fk Not Null
Comments..... Nvarcher
PostedDate.... DateTime default Getutcdate()
PostersName ..... Nvarchar Not Null.

Now I assume a user is reading article number 3.
If they want to post a feedback on that article, I want article ID3 to be inserted in the foreign key field.
I simply can not get it to work. Can it be that I am using SqlDatasource or should I use Objects etc?
Any more guaidance will be appreciated.
cheers,
yousaid


  #4 (permalink)  
Old April 8th, 2007, 03:46 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

It should work, with both the SqlDataSource and the ObjectDataSource.

Are you using a QueryString parameter?

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #5 (permalink)  
Old April 8th, 2007, 04:01 PM
Authorized User
 
Join Date: Apr 2006
Location: , , USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Greetings,
<...Are you using a QueryString parameter?....>

Yes, Maybe there's something I am doing wrong.
I tried using the instructiongs for the Blog and subsituting for my needs. Then I realized that the archtecture for both apps is differrnt and decided to implement it using SqlDatasource.
Maybe there's something I am doing wrong.
Anymore help will be appreciated.
Cheers,
yousaid

  #6 (permalink)  
Old April 8th, 2007, 04:10 PM
Authorized User
 
Join Date: Apr 2006
Location: , , USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Greetings,

Items #2 and #5 is where I am having problems. Specifically, I am unable to pass the contentId of the article and have it inserted into the comments table.
Cheers,
yousaid

  #7 (permalink)  
Old April 8th, 2007, 04:18 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

You'll need to post your code. It's hard to suggest anything without seeing what you're doing.

Please post the relevant code for your pages, controls and data access code. Also, please describe how the page is called and what query string info you pass.

Cheers,

Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #8 (permalink)  
Old April 10th, 2007, 03:56 PM
Authorized User
 
Join Date: Apr 2006
Location: , , USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The problem I have is how to PASS THE CONTENTID and insert it into the DB. That is, a user clicks on the Read more, they are taken to the contentDetails page. At the bottom, I have my comments control, for the comments from readers. Any ideas on how to capture this field?

My Comments control looks like this:

Protected Sub btncomments_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncomments.Click
        Dim myObj As New CommentsDB
        myObj.Savecomments(CommentId.Text, _ // I need this field passed as hidden field
                          txtemail.Text, _
                          txtcomment.Text)
    End Sub

       Enter Subject:
        <asp:TextBox ID="txtsubject" runat="server"></asp:TextBox><br />
        <br />
        Enter email: &nbsp; &nbsp; &nbsp;<asp:TextBox ID="txtemail" runat="server"></asp:TextBox><br />
        <br />
        Enter name: &nbsp;&nbsp; &nbsp;<asp:TextBox ID="txtname" runat="server"></asp:TextBox><br />
        <br />

My Comments table looks like this:
-------------------------------
CommentId PK Not Null
ContentID Fk ………….. From
Comment nvarchar

More fields…

My Comments class looks like this
--------------------------------------
Public Function Savecomments(ByVal _CommentId As Integer, _
      ByVal _PosterEmail As String, _
      ByVal _Comments As String) As Boolean

        Dim sqlConn As New SqlConnection(ConnectionStrings("Cms").ConnectionS tring)
        Dim cmd As New SqlCommand("sprocContentcommentsInsert", sqlConn)
        cmd.Parameters.Add("@contentId", SqlDbType.Int).Value = _contentid
        cmd.Parameters.Add("@PosterCity", SqlDbType.NVarChar, 50).Value = _PosterCity
        cmd.Parameters.Add("@Comments", SqlDbType.NText).Value = _Comments

        Try
            sqlConn.Open()
            cmd.CommandType = CommandType.StoredProcedure
            Savecomments = cmd.ExecuteNonQuery()
        Catch
            Throw
        Finally
            sqlConn.Close()
            cmd.Dispose()
            sqlConn.Dispose()
        End Try

    End Function

Thanks,
yousaid

  #9 (permalink)  
Old April 10th, 2007, 04:08 PM
Imar's Avatar
Wrox Author
Points: 72,055, Level: 100
Points: 72,055, Level: 100 Points: 72,055, Level: 100 Points: 72,055, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,086
Thanks: 80
Thanked 1,587 Times in 1,563 Posts
Default

If you have the ID of the content item in the Query String, you can retrieve it from there:

Dim contentId As Integer = Convert.ToInt32(Request.QueryString.Get("ContentId "))

Then you can pass contentId to your method.

HtH,

Imar


---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
  #10 (permalink)  
Old April 12th, 2007, 11:34 AM
Authorized User
 
Join Date: Apr 2006
Location: , , USA.
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for your help, I GOT it working. Now I have one other question.
One the text fields I have On the comments form (ContentDetails page) is "Subject" that that is, the Title of the article that the reader is about to comment on. I don't want the reader to have to enter this. I want it pre-populated so I used this.

Protected Sub txtsubject_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtsubject.DataBinding
        txtsubject.Text = "Re:" & CType(FindControl("litTitle"), Label).Text

But it does not work and Throw no erros. That is the textfield does not get Pre-poluted as expected. I have even tried on puting it onPageLoad it still does not work.
Thanks agian,
yousaid

    End Sub

 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 13 - CMS gedgecc BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 2 November 15th, 2012 09:19 AM
CMS Envelope problem chapter 9 luke.koziol BOOK: Beginning Cryptography with Java 1 May 6th, 2007 05:15 PM
problems with chapter 13 cms cyclonic BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 5 March 16th, 2007 04:25 AM
CMS (chapter 13) website integration nick.kirby BOOK: Beginning PHP, Apache, MySQL Web Development ISBN: 978-0-7645-5744-6 1 August 3rd, 2006 04:33 AM
Problems with chapter 13 cms hooligan BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 6 July 24th, 2005 12:19 AM



All times are GMT -4. The time now is 09:33 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.