Wrox Programmer Forums
|
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional 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
 
Old October 20th, 2004, 07:33 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default Storing and Displaying Formatted Strings

Greetings to all.

I have to display chemical equations and algebric equations on html page.
These equations are the part of the questions in an online examination.
i don't want to use images for performance considerations.
The questions are being composed offline and uploaded to online database. (MS Access for now. May be SQL Server in future)

My Problem is:

How can i store formatted strings in database involving special characters and superscript and subscript?

How can we retrieve the string from database along with formatting to display them correctly?

Anubhav Kumar
__________________
Anubhav Kumar
http://anubhavtimepass.blogspot.com/
 
Old October 20th, 2004, 10:34 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Anubhav Kumar,

There are tags for Superscript and SubScript. Here you go.
Code:
Do you want to see what is <sub>SubScript</sub> and how does a <sup>SuperScript</sup> look?
Check this link for Special Characters

When you store data on to db, you can store the formatted string, so that just read from db and display would give you the formatted effect.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 20th, 2004, 12:32 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

You want to use a string like in the previous post, and then Server.HtmlEncode() when you store it in the database. Then do Server.HtmlDecode() when showing to the screen.

Brian
 
Old October 20th, 2004, 01:10 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Actually there is no HTMLDECODE as such. So you got to write a function something like this, that does the decode for you, when displaying the content.
Code:
Private Function HTMLDecode(byVal encodedstring)
    Dim tmp, i
    tmp = encodedstring
    tmp = Replace( tmp, "&quot;", chr(34) )
    tmp = Replace( tmp, "&lt;"  , chr(60) )
    tmp = Replace( tmp, "&gt;"  , chr(62) )
    tmp = Replace( tmp, "&amp;" , chr(38) )
    tmp = Replace( tmp, "&nbsp;", chr(32) )
    For i = 1 to 255
        tmp = Replace( tmp, "(*)#" & i & ";", chr( i ) )
        There is some issue with the & used along with # here.
        So I have used (*) in the previous line. Replace that with &
        Will post a feedback on this issue.
    Next
    HTMLDecode = tmp
End Function
Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 21st, 2004, 07:01 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Sure there is an HTMLDecode, see MSDN: [link]http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwebhttpserverutilityclasshtmldecodetopi c.asp[/link].

Brian
 
Old October 21st, 2004, 11:35 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Brian,

Looks like that page doesn't exist. Takes me to 404 error - Location Cannot Be Found
Can you point me to the right page if any?

Is that true? I never knew that. Then why does that show me an error when I try to use?
Error Type:
Microsoft VBScript runtime (0x800A01B6)
Object doesn't support this property or method: 'Server.HTMLDecode'

And google too never throws me an MS site link related to that. Wondering!

May be .Net's SERVER object supports HTMLDECODE, not the ASP SERVER object.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 21st, 2004, 12:06 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

When I originally submitted the post, I didn't even realize that this was ASP 3. My apologies.

Brian
 
Old October 25th, 2004, 04:59 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

Thanks for consideration to all.

Dear Vigay G.

Its true that the solution given by you and Brians will definetly work. I already know that. I just want a suggestion, is there any tool through which we can compose html formatted pages and store them in databases?

Anubhav Kumar
 
Old October 25th, 2004, 06:57 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Anubav,

May be you can develop one such, considering all the points to format that and store into database which can be reusable. I haven't come across such tool as such.

Cheers!

_________________________
- Vijay G
Strive for Perfection
 
Old October 25th, 2004, 09:42 AM
Friend of Wrox
 
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anubhav.kumar
Default

Dear Vijay G.

I am planning to develop a tool in VB for that. The real stuck for me is to implement editing commands for superscript, subscript and special characters in Rich Text Box

I know this is asp forum but the problem is realated . Please don't mind

Anubhav Kumar





Similar Threads
Thread Thread Starter Forum Replies Last Post
Storing images in Database and displaying them Manoj Bisht ASP.NET 1.x and 2.0 Application Design 4 February 6th, 2010 03:06 AM
NOT WELL FORMATTED pallone XSLT 7 June 24th, 2008 04:45 PM
How to store and retrieve formatted strings in db jessi Classic ASP Professional 2 March 9th, 2007 07:27 AM
problem in the displaying two strings abhit_kumar JSP Basics 0 March 15th, 2005 05:56 AM
Storing a unknown number of strings to an Array PanzarPaw Classic ASP Basics 4 November 21st, 2003 12:14 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.