 |
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|
|

April 8th, 2007, 01:19 PM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 8th, 2007, 01:45 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

April 8th, 2007, 03:39 PM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 8th, 2007, 04:01 PM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 8th, 2007, 04:10 PM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

April 8th, 2007, 04:18 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

April 10th, 2007, 03:56 PM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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: <asp:TextBox ID="txtemail" runat="server"></asp:TextBox><br />
<br />
Enter name: <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
|
|

April 10th, 2007, 04:08 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
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.
|
|

April 12th, 2007, 11:34 AM
|
|
Authorized User
|
|
Join Date: Apr 2006
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
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 |
|
 |