views:

32

answers:

1

Hi,

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/ViewBlog/21

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?

A: 

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.

DaveB
'<%=txtEditor.ClientID%>' should be '#<%=txtEditor.ClientID%>' which works thanks.
N00b
any idea how to get the preview working witht he form? I know you have to edit previewParserPath in the set.js?
N00b