Print Page | Close Window

textarea from database

Printed From: Web Wiz Forums
Category: Web Wiz Web App Support Forums
Forum Name: Web Wiz Rich Text Editor (RTE)
Forum Description: Support forum for the Web Wiz Rich Text Editor (RTE).
URL: https://forums.webwiz.net/forum_posts.asp?TID=12896
Printed Date: 28 March 2026 at 9:03am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: textarea from database
Posted By: pablo_montiel
Subject: textarea from database
Date Posted: 09 December 2004 at 5:23am
Hi, I need some help to test how to retrieve data into the RTE_textarea.asp file from a database.

This example works:
     strEditorContent = "<div style=""text-align: center; font-family: arial,helvetica,sans-serif;""> <h2>Welcome to Web Wiz Rich Text</h2> Free replacement WYSIWYG Editor for your textareas </div>"

But I need to retrieve data into the strEditorContent, from the field Text of my database.


This is working fine in the textarea for NON rich text editors (message_forma_inc.asp):
<%=Replace(Replace(Text,"&","&"),"<","<")%>

But, WHAT must I write to get the same effect in the RTE_textarea.asp ???



Replies:
Posted By: WebWiz-Bruce
Date Posted: 09 December 2004 at 7:54am
Just display the data as you want it to be displayed in the text area in the RTE_textarea.asp as if it where a normal web page. IE. between the HTML <body> tags.

You can use the built in querystrings to pass across to the page which record to get from the database.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: pablo_montiel
Date Posted: 09 December 2004 at 8:40am
I have the following code in my default page, and it works fine with the NON rich text browser, Can you "more detail" explain me WHAT I should put in my RTE_textarea.asp to work ?

<!--#include file="RTE/includes/browser_page_encoding_inc.asp" -->
<%
'--- Querish Querystring ---'
Dim Requested, DelRecNo
Requested = Request.Querystring("Entry")
Delete = Request.Querystring("Delete")

If (IsNumeric(Requested) = False) OR (Len(Requested) = 0) Then Requested = 0

If Request.Form("Action") <> "Post" Then

'--- Open set ---'
    If (Requested <> 0) AND (Delete <> "True") Then
    Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
    ElseIf Requested = 0 Then
    Records.Open "SELECT * FROM Data ORDER By RecordID DESC",Database, 1, 3
    Else

    Database.Execute "DELETE FROM Data WHERE RecordID=" & Requested
    Database.Close
    Set Records = Nothing
    Set Database = Nothing
    Response.Redirect(SiteURL & PageName)

    End If

If NOT Records.EOF Then

'--- Setup Variables ---'
   RecordID = Records("RecordID")
   Title = Records("Title")
   Text = Records("Text")

End If

Records.Close
%>
<Form Name="frmAddMessage" Method="Post" onSubmit="document.getElementById('Submit').disabled=true;"& gt;
<input Name="Action" type="hidden" Value="Post">
             <P><span id="Label1">Title : </span><input Name="Title" type="text" value="<%=Replace(Title,"""",""")%>" style="width:80%;" onChange="return setVarChange()"> </P>

             <P>Content :<br>
             <table border="0" cellpadding="1" cellspacing="0" width="100%">
                <tr>
                <td class="td01" align="left">

<%
'Change this to the path to your RTE files
Const strPathToRTEFiles = "RTE/"           'This needs to hold the path to the RTE files


'The form name/id for the Web Wiz Rich Text (RTE) textarea is 'message'
%>
<!-- include the rich text editor -->
<!--#include file="RTE/RTE_editor_inc.asp" -->



                </td>
                </tr>

             <tr>
             <td colspan="2">
             </tr>
                </table>
             </P>


Posted By: WebWiz-Bruce
Date Posted: 09 December 2004 at 10:56am
You need to open the database in the RTE_textbox.asp file and read the data into that file.

The RTE editor can't use the normal text area, instead the text area is actually an Iframe, what you are looking at is another page in an Iframe with design mode enabled.

Look at it as if the RTE_textarea.asp another web page that simply opens in an Iframe.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: pablo_montiel
Date Posted: 09 December 2004 at 12:35pm
I am really a newbie an sorry about my insistence.
If I use this (at RTE_textarea.asp):

     strEditorContent = "<div style=""text-align: center; font-family: arial,helvetica,sans-serif;""> <h2>Welcome to ...</h2></div>"

it works.-

But If I use:
       strEditorContent = Replace(Replace(Text,"&","&"),"<","<")

it says that the Variable TEXT is not defined (that Replace: works fine in the message_forma_inc.asp file, but not in the RTE_textarea.asp ).

So the question is:
What must I write after: ""strEditorContent = "" or what must I write to retrieve data from the TEXT field so I could EDIT the RTE message I posted before into the database ?

Thanks in advance.


Posted By: WebWiz-Bruce
Date Posted: 09 December 2004 at 2:06pm
This bit:-

--- Open set ---'

    If (Requested <> 0) AND (Delete <> "True") Then
    Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
    ElseIf Requested = 0 Then
    Records.Open "SELECT * FROM Data ORDER By RecordID DESC",Database, 1, 3
    Else

    Database.Execute "DELETE FROM Data WHERE RecordID=" & Requested
    Database.Close
    Set Records = Nothing
    Set Database = Nothing
    Response.Redirect(SiteURL & PageName)

    End If

If NOT Records.EOF Then

'--- Setup Variables ---'
   RecordID = Records("RecordID")
   Title = Records("Title")
   Text = Records("Text")

End If


needs to be in the RTE_textarea.asp, as the RTE_textarea.asp file is an iframe it is a sepprate web page, so any variables used in this file need to be declared in this file.

Look at RTE_textarea.asp as a sepprate file, you may find it easier while sorting out the page to open the file RTE_textarea.asp in it's own browser window.

Right click in your browser on the textrea in the RTE and select 'open frame in new window'.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: pablo_montiel
Date Posted: 09 December 2004 at 3:43pm
thanks! I think I am near the solution by now BUT, there is an error: Expected 'END' in this code of my RTE_textarea.asp

Do you know where the problem could be ??

<% @ Language=VBScript %>
<% Option Explicit %>
<!--#include file="includes/RTE_setup.asp" -->
<!--#include file="functions/RTE_functions_common.asp" -->
<%


'Set the response buffer to true as we maybe redirecting
Response.Buffer = True

'Make sure this page is not cached
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 2
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "No-Store"


Dim strEditorContent     'Holds the editors pre-filled content

Dim strQueryString1
Dim strQueryString2
Dim strQueryString3

strQueryString1 = Request.QueryString("QS1")
strQueryString2 = Request.QueryString("QS2")
strQueryString3 = Request.QueryString("QS3")


'--- Querish Querystring ---'
Dim Requested, DelRecNo
Requested = Request.Querystring("Entry")
Delete = Request.Querystring("Delete")

If (IsNumeric(Requested) = False) OR (Len(Requested) = 0) Then Requested = 0

If Request.Form("Action") <> "Post" Then

'--- Open set ---'
    If (Requested <> 0) AND (Delete <> "True") Then
    Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
    ElseIf Requested = 0 Then
    Records.Open "SELECT * FROM Data ORDER By RecordID DESC",Database, 1, 3
    Else

    Database.Execute "DELETE FROM Data WHERE RecordID=" & Requested
    Database.Close
    Set Records = Nothing
    Set Database = Nothing
    Response.Redirect(SiteURL & PageName)

    End If

If NOT Records.EOF Then

'--- Setup Variables ---'
   RecordID = Records("RecordID")
   Text = Records("Text")


     strEditorContent = Replace(Replace(Text,"&","&"),"<","<")


End If

Records.Close
     

%>
<html>
<head>
<!--#include file="includes/browser_page_encoding_inc.asp" -->


<script language="javascript">
function enableDesignMode() {<%
If RTEenabled = "Gecko" Then Response.Write("     document.desig nMode = 'on'")
%>     }
</script>
<STYLE>
td {border:1px dotted #CCCCCC;}
</STYLE>
</head>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" onLoad="setTimeout('enableDesignMode()', 20);">

<% = strEditorContent %></body>

</html>


Posted By: pablo_montiel
Date Posted: 09 December 2004 at 3:48pm
My ORIGINAL edit page, was this one (without RTE):

<DIV id=content>
<%
'--- Querish Querystring ---'
Dim Requested, DelRecNo
Requested = Request.Querystring("Entry")
Delete = Request.Querystring("Delete")

If (IsNumeric(Requested) = False) OR (Len(Requested) = 0) Then Requested = 0

If Request.Form("Action") <> "Post" Then

'--- Open set ---'
    If (Requested <> 0) AND (Delete <> "True") Then
    Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
    ElseIf Requested = 0 Then
    Records.Open "SELECT * FROM Data ORDER By RecordID DESC",Database, 1, 3
    Else

    Database.Execute "DELETE FROM Data WHERE RecordID=" & Requested
    Database.Close
    Set Records = Nothing
    Set Database = Nothing
    Response.Redirect(SiteURL & PageName)

    End If

If NOT Records.EOF Then

'--- Setup Variables ---'
   RecordID = Records("RecordID")
   Title = Records("Title")
   Text = Records("Text")

End If

Records.Close
%>
<Form Name="AddEntry" Method="Post" onSubmit="return setVar()">
<input Name="Action" type="hidden" Value="Post">
             <P><span id="Label1">Title : </span><input Name="Title" type="text" value="<%=Replace(Title,"""",""")%>" style="width:80%;" onChange="return setVarChange()"> <a href="?Entry=<%=Requested%>&Delete=True" title="DELETE this entry" onClick="return confirm('Warning! If You Continue Entry #<%=Requested%> Will Be DELETED.')"><img src="<%=SiteURL%>Images/Delete.gif" width="15" height="15" border="0"></a></P>

             <P>Content :<br>
             <table border="0" cellpadding="1" cellspacing="0" width="100%">
                <tr>
                <td class="td01" align="left"> </td>
                </tr>

             <tr>
             <td colspan="2">
             <textarea Name="Content" DESIGNTIMEDRAGDROP="96" style="height:10em;width:100%;" onChange="return setVarChange()"><%=Replace(Replace(Text,"&","&")," <","<")%></textarea>
             </tr>
                </table>
             </P>


             <P></P>
             <Input Type="submit" Value="Save">
        </form>
<% Else
'Dimension variables
Dim EntryCat        &nbs p;   'Category

EntryCat = Request.Form("Category")

'### Filter & Clean ###
EntryCat = Replace(EntryCat,"'","'")
EntryCat = Replace(EntryCat," ","%20")

'### Open The Records Ready To Write ###
Records.CursorType = 2
Records.LockType = 3

    If Requested <> 0 Then
    Records.Open "SELECT * FROM Data WHERE RecordID=" & Requested,Database, 1, 3
    Else
    Records.Open "SELECT * FROM Data ORDER By RecordID DESC", Database
    End If

Records("Title") = Left(Request.Form("Title"),80)
Records("Text") = Request.Form("Content")

Records.Update
Records.Close

Response.Write "<p align=""Center"">Entry Update Successful</p>"
Response.Write "<p align=""Center""><a href=""" & SiteURL & PageName & """>Back</font></a></p>"

End If %>
</Div>



Posted By: pablo_montiel
Date Posted: 10 December 2004 at 7:33am
Please, somebody with some ASP knowledge help me with the code recently posted. I am testing the possibility to use RTE while ADD entries to a db and while EDITING past entries. While ADDING works great, but TO EDIT I canīt SEE on the EDIT PAGE the content from the DB in a Rich text browser.
It works fine with non rich text browsers.



Posted By: WebWiz-Bruce
Date Posted: 10 December 2004 at 11:30am
It maybe worth waiting for the full version to be released, hopefully next week (time permitting) as I plan to include some tutorials and various examples of how to use the editor, including one that will save and edit to an access database.

-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting


Posted By: cbeaudry
Date Posted: 14 December 2004 at 7:46pm
I worked around this issue by assigning session variables in my "add" and "edit" pages. Because I'm using the editor in different parts of my CMS, I could not define the value of strEditorContent in the RTE_textarea.asp file alone. The data for that string had to be able to come from different tables in my database.
 
The workaround requires editing the pages where the forms reside so you need to know simple coding but it basically boiled down to this:
 
On the RTE_textarea.asp page, I change the value at the bottom from strEditorContent to Session("strEditorContent")
 
On the pages where I add a record, I define the variable as:
 
Session("strEditorContent") = ""
 
On the edit pages, I define the variables right after opening up the recordset:
 
Session("strEditorContent") = rs.Fields.Item("field").Value
 
That also makes the code defining strEditorContent in the display_message.asp page irrelevant so I commented it out. Any instance of the variable was replaced with the session variable.
 
No, it's not perfect but it works. It's also important to make sure that non-cached pages show up when the add and edit files are loaded into the browser. Of course, that opens up a whole other can of worms because of the ways "no-cache" in the header works in different browsers. For a tutorial on work around for that, see http://www.htmlgoodies.com/beyond/nocache.html
 
I don't know how folks will react to this (since it's not really integrated into the whole RTE "system") but that's how I got it to work for me.


Posted By: WebWiz-Bruce
Date Posted: 15 December 2004 at 4:27am
Session varaibles are not reliable so I would avoid them.

The built in querystings:- QS1, QS2, and QS3

Should allow youn to pass database record ID's etc. to the RTE_textbox.asp page as they are passed from the page you place the RTE in by adding there values to the end of the part that opens the IFrame for the text area.

Also to prevent caching (which IE is very bad at with IFrames) when the IFrame is opened the following line of code is used:-

RTE_textarea.asp?noCache=" & CInt(RND * 2000) & "

This then adds a random number to the link, which prevents the caching problem.


-------------
https://www.webwiz.net/web-wiz-forums/forum-hosting.htm" rel="nofollow - Web Wiz Forums Hosting
https://www.webwiz.net/web-hosting/windows-web-hosting.htm" rel="nofollow - ASP.NET Web Hosting



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net