ASP
  Home arrow ASP arrow Page 5 - Building a WYSIWYG HTML Editor Part 2/2
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
VeriSign Whitepapers 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
IBM developerWorks
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP

Building a WYSIWYG HTML Editor Part 2/2
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 56
    2002-04-12

    Table of Contents:
  • Building a WYSIWYG HTML Editor Part 2/2
  • Creating the database
  • Implementing the WYSIWYG HTML editor
  • Implementing the WYSIWYG HTML editor (contd.)
  • Displaying the news posts
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    Iron Speed
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    Building a WYSIWYG HTML Editor Part 2/2 - Displaying the news posts


    (Page 5 of 6 )

    As I'm sure you can guess, it's extremely easy to display the news posts. Let's create a web page to view the news posts now, sorted by either topic or author. Our example will implement frames, so create a new page called news.html and enter the following code into it:

    <html> <head> <title>View News</title> </head>
    <frameset cols="200,*">
    <frame name="menu" target="main" src="menu.asp">
    <frame name="main">
    </frameset>
    </html>


    The menu frame will list both topics and authors for which we can view news. It will link to a page called viewnews.asp, which we will create in a minute. The source code for the menu frame resides in menu.asp and looks like this:

    <!-- #INCLUDE file="db.asp" -->
    <%
    dim objConn dim objRS
    set objConn = Server.CreateObject("ADODB.Connection")
    set objRS = Server.CreateObject("ADODB.Recordset") objConn.Open
    dbConnString objRS.ActiveConnection = objConn
    Response.Write "<b>Topics:</b><br>"
    objRS.Open "select * from newsTopics order by topic asc"
    while not objRS.EOF
    Response.Write "<a target='main' href='viewnews.asp?how=topic&topicId=" & objRS("topicId") & "'>"
    Response.Write objRS("topic") & "</a><br>"
    objRS.MoveNext
    wend
    objRS.Close Response.Write "<br><b>Authors:</b><br>"
    objRS.Open "select * from newsAuthors order by name asc"
    while not objRS.EOF
    Response.Write "<a target='main' href='viewnews.asp?how=author&authorId=" & objRS("authorId") & "'>"
    Response.Write objRS("name") & "</a><br>"
    objRS.MoveNext wend
    %>

     
    Here's how the frame looks with menu.asp:
     
    The menu.asp frame in action 

    The right side frame loads viewnews.asp with the query string arguments from the links in the left frame. Its source code looks like this:

    <!-- #INCLUDE file="db.asp" -->
    <%
    dim how
    dim topicId
    dim authorId
    dim query
    dim objConn
    dim objRS
    how = Request.QueryString("how")
    topicId = Request.QueryString("topicId")
    authorId = Request.QueryString("authorId")
    query = "" set objConn = Server.CreateObject("ADODB.Connection")
    set objRS = Server.CreateObject("ADODB.Recordset")
    objConn.Open dbConnString
    objRS.ActiveConnection = objConn
    if how = "topic" then
    query = "select * from newsPosts where topics like " & _ "'%" & topicId & "%'"
    elseif how = "author" then
    query = "select * from newsPosts where authorId = " & authorId
    else
    Response.Write "<b>ERROR: You didn't select a valid type</b>"
    Response.End
    end if
    objRS.Open query
    while not objRS.EOF
    response.write "<h2>" & objRS("title") & "</h2>"
    response.write "<b>Author Id: </b>" & objRS("authorId") & "<br>"
    response.write "<b>Topics: </b>" & objRS("topics") & "<br>"
    response.write objRS("newsPost") & "<br><hr><br>"
    objRS.MoveNext wend
    %>


    Viewnews.asp works with the query string variables how, topicId and authorId, querying the database with a different query depending on whether or not we want to view news by topic or by author. The query is generated as a LIKE query, however an IN query could also be used. If I clicked on a topic in the left frame, then the query string and SQL query would look like this:

    http://localhost/viewnews.asp?how=topic&topicId=6

    select * from newsPosts where topics like '%6%'

    Likewise if I clicked on an author in the left frame, the query string and SQL query would look like this:

    http://localhost/viewnews.asp?how=author&authorId=1

    select * from newsPosts where authorId = 1


    Last but not least, here's a screenshot from when I clicked on the developer topic:
     
    The result of clicking on the developer topic 

    The news post's title, author ID and topic(s) are displayed as well as the HTML for the actual post. With just a bit of tweaking, this page could easily be changed to fit into any content driven web site, just like I've done with
    Socket6.

    More ASP Articles
    More By Mitchell Harper


     

    ASP ARTICLES

    - Central Scoreboard with Flash and ASP
    - Calorie Counter Using WAP and ASP
    - Creating PGP-Encrypted E-Mails Using ASP
    - Be My Guest in ASP
    - Session Replacement in ASP
    - Securing ASP Data Access Credentials Using t...
    - The Not So Ordinary Address Book
    - Adding and Displaying Data Easily via ASP an...
    - Sending Email From a Form in ASP
    - Adding Member Services in ASP
    - Removing Unconfirmed Members
    - Trapping HTTP 500.100 - Internal Server Error
    - So Many Rows, So Little Time! - Case Study
    - XDO: An XML Engine Class for Classic ASP
    - Credit Card Fraud Prevention Using ASP and C...


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway