Lets understand how to embed code formatting in Asp.net Application. This can be useful while user enters the code online, and we need to format the code and able the preview the same. Example, on online forum or blog if user enters code, application should be smart to understand the part of code and able to format. This Code Format utility used Manoli Csharp Format, I have used the sourcecode and demonstrate how this can be useful to implement code format in asp.net application. Step1: Download Sourcecode from Manoli Online Code Format To accomplish this task, download source code of manoli csharpformat. Direct link for downloading Sourcecode of Manoli CsharpFormat Step2: Compile the Class Library Project to generate binaries. Step3: Create an asp.net application, while will be used to display Formatted Code. Step4: Right Click project and Add Reference. - Add Reference of binaries generated by Manoli Code Format Class Library Project Step5: Add csharp.css file available with Manoli Code Format Sourcecode. - Right Click and Add Existing Item and browse through location where csharp.css file is located. (This file will be available with sourcecode) - And add link reference in default.aspx <link href="csharp.css" rel="stylesheet" type="text/css" /> After adding .dll file and .css file your solution explorer. Step6: Add the 2 textbox controls, 1 button control and 1 label control. 2 – Textbox control, 1 for taking input and other for displaying generated html code. 1 – Label control for displaying preview. Step7: Add ValidateRequest="false" in page derective for taking HTML Input <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Step8: Looking class diagram of Manoli Code Formatter - You can create object for each language you wish to format. Step9: Writing a Code to make everything works. protected void btnPreview_Click(object sender, EventArgs e) { |
Collection and sharing of, interview questions and answers asked in various interviews, faqs and articles.....
how to embed code formatting in Asp.net Application?
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment