Help getting started

Last post 05-17-2005, 8:31 AM by DG252. 5 replies.
Sort Posts: Previous Next
  •  08-16-2004, 12:19 PM 1511

    Help getting started

    Hi. I'm a first-time CuteEditor user and am really stuck. We've got the code on the server and put the script on the page we want to edit, but I don't know what to do now. Can anybody give a really lame-o beginner some advice on how to use this? I really want it to work, but I'm lost as to what do do.

    Thanks very much.

  •  08-17-2004, 12:02 AM 1517 in reply to 1511

    Re: Help getting started

    Hi,

     

    Let's start from creating a HTML Form Page. Then we replace the textarea with CuteEditor.

     

    Create a new HTML page and name it 'CuteEditorTest.asp' Copy the following code and paste it into the body section of 'CuteEditorTest.asp' page :

     

    Inserting Records :

    <form action="target.asp" method="post" ID="Form1">

    title:
    <input type="text" name="title" ID="Text1"><br>
    Comments : <textarea name="comments" cols="20" rows="5" ID="Textarea1"></textarea><br>
    <input type="submit" value="submit" ID="Submit1" NAME="Submit1">

    </
    form>

    The above HTML code creates a simple Form asking for title and comments. You can later change them according to what you want your users to enter.

     

     

    ASP Action Page


    Create a new ASP page 'target.asp' in the same directory as the above HTML page. Copy and paste the following ASP code into 'target.asp' page :

     

    <%

    ' Declaring variables

    Dim title, comments, data_source, con, sql_insert


    ' Receiving values from Form

    title = ChkString(Request.Form("title"))

    comments = ChkString(Request.Form("comments"))

    data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _

    Server.MapPath("form.mdb")

    sql_insert = "insert into news (title, comments) values ('" & _

    title& "', '" & comments & "')"

    ' Creating Connection Object and opening the database

    Set con = Server.CreateObject("ADODB.Connection")

    con.Open data_source

    con.Execute sql_insert


    ' Done. Close the connection

    con.Close

    Set con = Nothing 

    ' A Function to check if some field entered by user is empty

    Function ChkString(string)

    If string = "" Then string = " "

    ChkString = Replace(string, "'", "''")

    End Function

     

    %>

     

    Our above ASP page 'target.asp' will receive values entered by user in the HTML Form and will first check to see if some fields have been left empty. Then it will insert those values into our Access database.
     

    Let's replace the regular textarea with CuteEditor:

     
     
    I hightlighted the changes we need to made.
     
    Create a new HTML page and name it 'CuteEditorTest.asp' Copy the following code and paste it into the body section of 'CuteEditorTest.asp' page :

     

     

    <!-- #include file = "include_CuteEditor.asp" --> 

    Inserting Records :

    <form action="target.asp" method="post" ID="Form1">

    title:
    <input type="text" name="title" ID="Text1"><br>
    Comments : <textarea name="comments" cols="20" rows="5" ID="Textarea1"></textarea>
     

    <%

        'Create a new editor class object

        Dim editor

        Set editor = New CuteEditor

        'Set the ID of this editor class

        editor.ID = "Editor1"

        editor.FilesPath = "CuteEditor_Files"

        editor.ImageGalleryPath = "/Uploads"

        editor.Draw()

        ' Retrieve the data from editor: Request.Form("Editor1_HTMLContent")

    %>

    <br>
    <input type="submit" value="submit" ID="Submit1" onfocus="save(Editor1)"> NAME="Submit1">

    </
    form>

     


     

    ASP Action Page


    Create a new ASP page 'target.asp' in the same directory as the above HTML page. Copy and paste the following ASP code into 'target.asp' page :

     

    <%

    ' Declaring variables

    Dim title, comments, data_source, con, sql_insert


    ' Receiving values from Form

    title = ChkString(Request.Form("title"))

    comments = ChkString(Request.Form("Editor1_HTMLContent"))

    data_source = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _

    Server.MapPath("form.mdb")

    sql_insert = "insert into news (title, comments) values ('" & _

    title& "', '" & comments & "')"

    ' Creating Connection Object and opening the database

    Set con = Server.CreateObject("ADODB.Connection")

    con.Open data_source

    con.Execute sql_insert


    ' Done. Close the connection

    con.Close

    Set con = Nothing 

    ' A Function to check if some field entered by user is empty

    Function ChkString(string)

    If string = "" Then string = " "

    ChkString = Replace(string, "'", "''")

    End Function

     

    %>

     

     

    Hope it helps.
     
    Let me know if you have any further questions.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-17-2004, 9:49 AM 1519 in reply to 1517

    Re: Help getting started

    Thanks, Adam. I'll share this with our tech guys today and see if we can't get it going. Appreciate your help and patience!
  •  08-17-2004, 4:39 PM 1530 in reply to 1517

    Re: Help getting started

    Adam -- I looked at this with one of our tech guys, and he said it appeared that we needed an Access database, which I hadn't seen mentioned in any of our pre-purchase discussions or documentation. Do we have to use Access to use CuteEditor, or can you provide a sample where it reads a file into the editor and then updates that file after previewing and saving?

     
    Thanks for your continued help and patience.
  •  05-12-2005, 3:15 PM 6628 in reply to 1517

    Re: Help getting started

    I copied the code you provided above into my application and it works very well!  Can you tell me how to tweak this code so that it UPDATES a record rather than creating a new one?  I saw several postings in the help forum related to this topic, but none were too helpful.   Most of them referred me to the link: http://asp101.com/samples/db_edit.asp.  Thanks.

  •  05-17-2005, 8:31 AM 6754 in reply to 6628

    Re: Help getting started

    Does anybody have any suggestions that could help me? 
View as RSS news feed in XML