Re: Another how do I get started question.

  •  10-13-2004, 1:12 PM

    Re: Another how do I get started question.

    Jill,

     

    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

View Complete Thread