EditLive! 9 Documentation : Basic ASP.NET Example Documentation

This page provides information on how to instantiate EditLive! within a web page using Active Server Pages in the .NET environment. This is intended as a basic sample only. Its purpose is only to demonstrate how EditLive! can be placed into a web page.

Getting Started

System Requirements
  • Microsoft IIS 6.0 Web Server with ASP.NET 3.0 or later installed
  • The EditLive! ASP.NET Server Control 
Required Skills

The following skills are required prior to working with this sample:

  • Developing Web-based forms in HTML
  • Developing ASP.NET Web Forms in C#
Installing the EditLive! Server Control Component

For information on how to install the EditLive! ASP.NET Server Control please see the EditLive! ASP.NET Installation Guide document in the SDK. This example assumes that you have read the document. Furthermore, it is assumed that you have set up a Web project for development and included the appropriate files for development with the EditLive! ASP.NET Server Control.

Source Code

This documentation includes a copy of the full source code needed for this example. You will find the completed source code in a file called BasicSample.aspx in the directory EDITLIVE_INSTALL/webfolder/aspnet/basic where EDITLIVE_INSTALL is the location where EditLive! is installed. In order to run this example add the BasicSample.aspx file to an ASP.NET Web project which includes a reference to the EditLiveJavaControl.dll file. Then example will then be available to browse to in the Web project concerned.

Instantiating EditLive! in an ASP.NET Page

1. Add a reference to the EditLiveJavaControl.dll in the relevant project. Also ensure that the EditLive! source files and libraries are present on the Web server. For more information on how to do this please see the ASP.NET Installation Guide document.

2. Create a new Web Form.

3. Using the Register directive create a prefix for the EditLive! Server Control and register the name space. In this case we will be using the prefix elj. The Namespace and Assembly values are both EditLiveJavaControl.

<%@ Register assembly="EditLiveJavaControl" namespace="EditLiveJavaControl" tagprefix="elj" %>

4. Declare a tag which represents the EditLive! Server Control and set the runat property to server.

<form id="form1" runat="server">
...
<elj:EditLiveJava runat="server" ... />
...
</form>

5. Specify the ID property for the control instance.

<form id="form1" runat="server">
...
<elj:EditLiveJava runat="server" ID="EditLiveJava1"  ... />
...
</form>

6. Specify the download directory for the instance of EditLive!. This is the location of editlivejava.jar and associated files. This defaults to /editlivejava.

<form id="form1" runat="server">
...
<elj:EditLiveJava runat="server" id="EditLiveJava1" 
DownloadDirectory="../../redistributables/editlivejava" 
... />
...
</form>

7. Specify the XML configuration file for the instance of EditLive!.

<form id="form1" runat="server">
...
<elj:EditLiveJava runat="server" id="EditLiveJava1"
DownloadDirectory="../../redistributables/editlivejava" 
ConfigurationFile="../../redistributables/editlivejava/sample_eljconfig.xml"
... />
...
</form>

8. Specify the initial contents of EditLive!. The content must be HTML-encoded.

<form id="form1" runat="server">
...
<elj:EditLiveJava runat="server" id="EditLiveJava1" 
DownloadDirectory="../../redistributables/editlivejava" 
ConfigurationFile="../../redistributables/editlivejava/sample_eljconfig.xml"
Content="&lt;p&gt;Default editor content&lt;/p&gt;&lt;p&gt;More content&lt;/p&gt;"
/>
...
</form>

The set of properties used in this example consists of the basic properties required to be set when creating an instance of EditLive! in an ASP.NET page. For more information see the ASP.NET Installation Guide and the EditLive! for Java Load Time Methods.

Retrieving Content from EditLive! for Java in an ASP.NET Page

The code listed in the various steps of the previous section details how to instantiate EditLive! within an ASP.NET page and specify the initial content. The following describes how to retrieve the content from the control in a server-side event handler.

1. Include a button on the page which will get the contents of EditLive! when clicked. This calls the function written in step 3 of this section.

<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />

2. Include a textbox on the page to display the content of EditLive! in once it has been retrieved.

<asp:TextBox ID="TextBox1" runat="server" Height="96px" TextMode="MultiLine" Width="252px" />

3. Write a server-side event handler to retrieve the content of EditLive! when the button is clicked. We simply read the Content property from the EditLiveJava control into the Text property of the textbox.

protected void Button1_Click(object sender, EventArgs e) {
    TextBox1.Text = EditLiveJava1.Content;
}

By default ASP.NET forms cannot post values containing HTML. In order to successfully post EditLive!'s content, you will need to ensure the page directive contains the validateRequest="false" parameter.

Summary

With the EditLive! ASP.NET Server Control, EditLive! can be quickly and easily integrated into an ASP.NET page. The server control allows for seamless integration with the ASP.NET Architecture, meaning that EditLive!'s content can be easily submitted to an ASP.NET server page and retrieved.

To run this example, change any required settings in the basicexample.aspx file. This file can be found in EDITLIVE_INSTALL/webfolder/aspnet/basic/, where EDITLIVE_INSTALL is the directory where you have installed EditLive!.

By default ASP.NET forms cannot post values containing HTML. In order to successfully post EditLive!'s content, you will need to ensure the page directive contains the validateRequest="false" parameter.

In ASP.NET 4.0, you also need to add the following to your web.config, in the <system.web> section:

<httpRuntime requestValidationMode="2.0" />