2011-11-17 3 views
0

현재 Ajax 도구를 사용하고 있습니다. HTMLEditorExtender는 C# ASP.NET 프로젝트에서 텍스트 상자를 WYSIWYG 편집기로 변환합니다. 초기 페이지로드시에는 많은 양의 포맷 된 텍스트와 테이블을 편집기에 표시합니다. 심지어 테이블.포스트 백 테이블의 AJAX HTMLEditorExtender가 표시되지 않습니다.

데이터는 asp : 패널에로드되고 패널의 항목/디스플레이는 실제로 익스텐더에로드되어 표시됩니다.

그러나 편집기에있는 모든 데이터를 세션에 저장하고 단추를 누른 후에도 WYSIWG 편집기의 모든 내용을 페이지 포스트 백의 텍스트 상자에로드되는 모든 내용을 표시하려면 테이블을 제외하고는 괜찮습니다. 그들은 꼬리표를 제안한다. 이 주변에 어쨌든 있습니까?

string strHTMLText = txtPN.Text; 
Session["ProgressNoteHTML"] = strHTMLText; 

그리고 내가 좋아하는 포스트 백에로드 오전 : 버튼에

ContentPlaceHolder cphMain = (ContentPlaceHolder)this.Master.FindControl("MainContent"); 
Panel pnlContent = (Panel)cphMain.FindControl("innerFrame"); 
StringBuilder sb = new StringBuilder(); 
StringWriter sw = new StringWriter(sb); 
HtmlTextWriter hw = new HtmlTextWriter(sw); 
pnlContent.RenderControl(hw); 
txtPN.Text = sb.ToString(); 
pnlContent.Visible = false; 

나는이 저장된 데 클릭

내가 처음에 페이지를로드하는 데 사용하고 코드는 이것이다 이 : 어떤 포스트 백은 태그가 표시되도록 할 이유에 원점에서

txtPN.Text = (string)Session["ProgressNoteHTML"]; 
ContentPlaceHolder cphMain = (ContentPlaceHolder)this.Master.FindControl("MainContent"); 
Panel pnlContent = (Panel)cphMain.FindControl("innerFrame"); 
pnlContent.Visible = false; 

어떤 아이디어 그들이하지 않는 페이지로드?

답변

0

동일한 문제가 있습니다. HTML 콘텐츠에서 확장 기능이 수행하는 기본 위생 처리와 관련이있는 것으로 보입니다. 나는 그것을 끌 수있는 방법을 찾지 못했지만, 그 해결 방법은 매우 간단합니다. 정리 된 태그를 적절한 태그로 바꾸는 Anti-Sanitizing 함수를 작성하십시오. 아래는 VB.Net로 작성된 것입니다. C# 버전은 매우 비슷해 보입니다.

Protected Function FixTableTags(ByVal input As String) As String 
    'find all the matching cleansed tags and replace them with correct tags. 
    Dim output As String = input 

    'replace Cleansed table tags. 
    output = output.Replace("&lt;table&gt;", "<table>") 
    output = output.Replace("&lt;/table&gt;", "</table>") 
    output = output.Replace("&lt;tbody&gt;", "<tbody>") 
    output = output.Replace("&lt;/tbody&gt;", "</tbody>") 
    output = output.Replace("&lt;tr&gt;", "<tr>") 
    output = output.Replace("&lt;td&gt;", "<td>") 
    output = output.Replace("&lt;/td&gt;", "</td>") 
    output = output.Replace("&lt;/tr&gt;", "</tr>") 

    Return output 
End Function 
2

Erik에서 제공하는 솔루션은 속성 값이 포함 된 테이블 태그에서 작동하지 않습니다. 예 : <table align="right">은 디코딩되지 않습니다. 또한 <img> 태그가 HTMLEditorExtender으로 인코딩되었음을 발견했습니다.

더 쉬운 방법은 Server.HTMLDecode() 방법을 사용하는 것입니다.

TextBox_Editor.Text = Server.HtmlDecode(TextBox_Editor.Text) 'fixes encoding bug in ajax:HTMLEditor 
관련 문제