 |
| 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
|
|
|
|

October 20th, 2004, 07:33 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

October 20th, 2004, 10:34 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

October 20th, 2004, 12:32 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

October 20th, 2004, 01:10 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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, """, chr(34) )
tmp = Replace( tmp, "<" , chr(60) )
tmp = Replace( tmp, ">" , chr(62) )
tmp = Replace( tmp, "&" , chr(38) )
tmp = Replace( tmp, " ", 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
|
|

October 21st, 2004, 07:01 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
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
|
|

October 21st, 2004, 11:35 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

October 21st, 2004, 12:06 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
|
|
When I originally submitted the post, I didn't even realize that this was ASP 3. My apologies.
Brian
|
|

October 25th, 2004, 04:59 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|

October 25th, 2004, 06:57 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
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
|
|

October 25th, 2004, 09:42 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2004
Posts: 109
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
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
|
|
 |