Question

I'm using markdownsharp with my asp.net forms website.

I want to use MarkItUp as my editor and have found a straight forward article on how to integrate with MVC which seems straight forward enough: http://rsolberg.com/2010/09/asp-net-mvc-markitup-rich-text-editor/

However, how do I do this with a forms website?

How do I get the MarkItDown Textarea on a postback and get the preview to work as well?

Was it helpful?

Solution

Place the Javascript and CSS file links in the head portion of the page just as you would with MVC. Then in your form, place a TextArea control. Set the rows and columns as needed.

<asp:TextBox ID="txtEditor" runat="server" TextMode="MultiLine" Columns="40" Rows="5" Text="" />

Then use JQuery to enable to functionality.

$(document).ready(function() {
        $('<%=txtEditor.ClientID%>').markItUp(mySettings);    });

Then on PostBack the contents of the editor will be available in the Text property of the TextBox control.

txtEditor.Text

This is not the only way to do this, you could also use a HTML TextArea control with a runat="server" attribute. Use whatever your personal preference is.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top