Hi all,
My first post to the community so please be kind :)
I have malformed HTML comments in a database. I found that by loading these records into the ckeditor and then viewing source mode the malformation get fixed. This is great! The issue is how to capture the fix so I can save it back to the db.
- I'm using vb.net for my proof of concept
- I load the bad html data into editor in my Default.aspx.vb - Page_Load()
- In the browser I click the source button and I see the correct (fixed) html
- accessing the "value" or the "innertext/html" properties returns the original bad text :(
- How do I get the "fixed" text returned?
- Can the "fixed" value be retrieved from the control? Am I doing something wrong?
- If it can't be I was toying with the idea of loading the control, programitically switching to "source" view, and copying the edior contents into the clipboard and then saving the clipboard contents.
- My problems with this are:
- How to programitically to "source" view without hitting the actual button on the menu
- How to copy to the clipboard ... I'm getting a threading (STA) error when I try to use the clipboard
aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="FindAndFixParagraphTags._Default" Debug="true" validateRequest="false"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>ParagraphTagFixer</title>
<script type="text/javascript" src="/ckeditor/ckeditor.js"></script>
<script type="text/javascript" src="/ckeditor/adapters/jquery.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<textarea id="editor1" name="editor1" cols="20" rows="25" runat="server"><p>Initial value.</p></textarea>
<script type="text/javascript">
CKEDITOR.replace('editor1',
{
customConfig: '',
toolbar:
[
{ name: 'document', items: ['Source'] }
]
});
</script>
</div>
<asp:Button ID="Button1" runat="server" Text="Button" />
<div>
<textarea id="output" name="output" cols="97" rows="50" runat="server"></textarea>
</div>
</form>
</body>
</html>
aspx.vb
Imports System.Threading
Partial Public Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim szHTMLBuffer As String
szHTMLBuffer = "<DIV><P>hello world"
editor1.Value = szHTMLBuffer
output.Value = editor1.InnerText
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
output.Value = "button push: " + editor1.InnerText
End Sub
End Classthank you :)
ps .. I attached the vb.net solution but had to rename the zip to txt so it would upload. Make sure to change the extension back to zip after downloading so it will extract properly.
