Results 1 to 10 of 10

Thread: forum style tags?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    forum style tags?

    Hi.
    I am wondering how I would go about approaching this.

    I am trying to create my own forum. Obviously as you can see with this forum, whenever you enter a URL, it will show it as a clickable URL to the website.

    How would I go about doing this in ASP.NET when we databind the data from SQL?

    Sure, we could add an opening and closing tag, and then just make that into a clickable link - but is this also a correct way of doing it?

    what about things like having bold text and so on - should I still do the whole tag thing?

    Say if this is the correct way of doing it, how would I convert the tags to the equivilent HTML on the fly when we are databinding the source to a datalist?

    Many thanks!

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,651

    Re: forum style tags?

    Databinding would not cut it in that case - you would need to retrieve the query result manually and parse the text for URLs to turn into HTML <a> tags. Most forum software uses regular expressions for that.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: forum style tags?

    oh databinding makes things easier tho...
    so pretty much I have to execute dataReader and go through each column and then regex it and set the label text property to the column appropriatly?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: forum style tags?

    If it's forum software, you don't want to allow HTML to be input by the users. Using tags would be the best way to go.

    The best way to go about it would be to store the tags as-is into your database, and only modify them when you are displaying them to the user. (Using regex, of course)

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: forum style tags?

    yeh I am aware of that but I just wanted to know how I can do this whilst databinding

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,174

    Re: forum style tags?

    Quote Originally Posted by Techno
    oh databinding makes things easier tho...
    so pretty much I have to execute dataReader and go through each column and then regex it and set the label text property to the column appropriatly?
    In which case, yes.

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: forum style tags?

    performance would be slower in that case no?

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  8. #8
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: forum style tags?

    string sRegExTags= @"\[([\w\s\=\"\'\:\//]+)\]([^\[]+)\[\/(\w+)\]";
    Last edited by Lord_Rat; Apr 17th, 2006 at 12:55 PM.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  9. #9
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497

    Re: forum style tags?

    And btw, my recommendation is actually to have two columns in your database. One for the content as-entered and one for content as-HTML-ified.

    When displaying your forum, use the content from the HTML-ified field.

    If you ever change what tags are allowed, recreate the HTML-ified field.

    If a user edits a post, show the content from the tags field.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  10. #10

    Thread Starter
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: forum style tags?

    Thanks

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width