RadEditor for ASP.NET AJAX

RadControls for ASP.NET AJAX

The example below demonstrates displaying database content to a RadEditor and saving changes to the database.

 

Configure the Web Application for RadEditor

In a new AJAX Enabled Web Application:

Add Data File

  1. Locate the Access database file "email.mdb" in the \<RadControls for ASP.NET AJAX installation folder>\Live Demos\App_Data.

  2. In the Solution Explorer, copy the "email.mdb" file to the project's App_Data folder.

Configure Controls in Designer

  1. Add a RadComboBox from the ToolBox to the web page. Set the RadComboBox properties:

  2. AutoPostBack = True

  3. Skin = Vista

  4. AllowCustomText = True

  5. Add a Standard Button control from the ToolBox to the web page. Set the Button ID property to "btnNew". Set the Text property to "New".

  6. Add a Standard Button control from the ToolBox to the web page. Set the Button ID property to "btnSave". Set the Text property to "Save".

  7. Open the RadEditor Smart Tag and set the the Skin to Vista from the drop down list.

Configure Editor Tools

  1. In the Property Window, click the RadEditor Tools property ellipses. This step will open the EditorToolGroup Collection Editor dialog.

  2. In the EditorToolGroup Collection Editor dialog, click the Add button. This will add an EditorToolGroup item to the collection.

  3. Click the EditorToolGroup item Tools property ellipses. This step will open the EditorTool Collection Editor dialog.

  4. Click the EditorTool Collection Add button. In the properties for the EditorTool, locate the Name property, click the drop down arrow and select "Bold" from the list.

  5. Click the EditorTool Collection Add button. In the properties for the EditorTool, locate the Name property, click the drop down arrow and select "Italic" from the list.

  6. Click the EditorTool Collection Add button. In the properties for the EditorTool, locate the Name property, click the drop down arrow and select "Underline" from the list.

  7. Click the OK button to close the EditorTool Collection Editor dialog.

  8. Click the OK button to close the EditorToolGroup Collection Editor dialog.

  9. The ASP.NET markup for the steps so far should look something like the example below:

    CopyASPX
    <telerik:RadComboBox
       ID="RadComboBox1"
       runat="server"
       AutoPostBack="True"
       OnSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"
       Skin="Vista"
       AllowCustomText="True">
    </telerik:RadComboBox>
    <asp:Button ID="btnNew" runat="server" OnClick="btnNew_Click" Text="New" />
    <asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" /><br />
    <telerik:RadEditor ID="RadEditor1" runat="server" Skin="Vista" Width="500px" Height="400px">               
       <Tools>
           <telerik:EditorToolGroup>
               <telerik:EditorTool Name="Bold" />
               <telerik:EditorTool Name="Italic" />
               <telerik:EditorTool Name="Underline" />
           </telerik:EditorToolGroup>
       </Tools>
    </telerik:RadEditor>

Handle Events in Code-Behind

  1. In the designer, double-click the surface of the web page to navigate to the Page_Load event handler. Replace the event handler with the following code:

  2. Add a series of helper methods to create a connection to the Access database, update, insert and read records:

  3. In the designer, double-click the RadComboBox control to create a SelectedIndexChanged event handler. Replace the event handler with the code below. In this snippet, the SelectedValue contains the ID for the selected record.

  4. In the designer, double-click the "btnNew" Button control to create a Click event handler. Replace the event handler with the code below.

  5. In the designer, double-click the "btnSave" Button control to create a Click event handler. Replace the event handler with the code below.

  6. Press F5 to run the application. As you change selections in the RadComboBox list, the content of the RadEditor should change in unison. Make changes to content and click the save button. Navigate to and from the edited record to verify that the content has been saved to the database.

See Also

Other Resources