Reputation: 1
I have a textarea using Summernote that allows entering text. I save to a SQL table. I'm retrieving from codebehind. The data displays just fine in the literal control but is blank for the textarea and summernote not showing toolbar. The literal control is mainly to test retrieval. I want to be able to load the data into summernote and edit the text.
aspx:
<textarea id="TextAreaSummary" name="TextAreaSummary" style="width:1000px;" ></textarea>
<script>
$(document).ready(function () {
var markupStr = '<%=GetSomeText%>';
$('#TextAreaSummary').summernote('code', markupStr);
$('#TextAreaSummary').summernote('disable');
});
code behind:
public string GetSomeText ;
protected void Page_Load(object sender, EventArgs e)
{
statusbind();
GetSomeText = SummaryHtml1.Text;
}
protected void statusbind()
{
//SQL connection info to stored procedure
SummaryHtml1.Text = reader["summarytext"].ToString();
GetSomeText= reader["summarytext"].ToString();
}
The SummaryHtml1.Text is displaying correctly in the literal. The GetSomeText was my attempt to read codebehind via the javascript into summernote since I can't use runat="server" and load summernote on the textarea.
My question: Is there a more reliable/correct way to get data into the textarea instead of what I'm doing (which isn't working right)? Thanks in advance.
Upvotes: 0
Views: 196
Reputation: 1
I think I mostly got this working. I had to add HttpUtility.JavaScriptStringEncode. Other than some formatting differences from literal, it seems to work now.
Upvotes: 0