How to hide generated javascript file in visual studio code

In this post I am going to show you a cool trick in visual studio code. Let's suppose you are writing typescript code in visual studio code and you want to hide generated javascript code.

Create .vscode folder in your folder and then create settings.json file and paste following code

{ "files.exclude": { "node_modules":true, "**/.git": true, "**/.DS_Store": true, "**/*.js.map": true, "**/*.js": {"when": "$(basename).ts"}     } }

How to create html helper in razor (.NET MVC)


Razor is an ASP.NET programming syntax used to create dynamic web pages with the C# or Visual Basic .NET programming languages.The Razor syntax is a template markup syntax, based on the C# programming language, that enables the programmer to use an HTML construction workflow[clarification needed]. Instead of using the ASP.NET .ASPX markup syntax with <%= %> symbols to indicate code blocks, Razor syntax starts code blocks with a @ character and does not require explicit closing of the code-block.

HTML Helper
Html helper are much like asp.net control that return html string.But HTML helpers are more lightweight. Unlike Web Form controls, an HTML helper does not have an event model and a view state.
In this post I will show you how to create Html helper in MVC.NET.There are two ways to create html helper in MVC.
Inline Helpers
These are create in the same view by using the Razor @helper tag. These helpers can be reused only on the same view.For example in following code snippet I have created a ToUpper html helper that wrap the text inside b tag and converts  the text to upper case 

@helper ToUpper(string text) { 
        
        @text.ToUpper()
    
    }
@{
    ViewBag.Title = "Demo";
    Layout = null;
}


@ToUpper(@ViewBag.Message)

Custom Helper
If you want to use your Html helper in application level then you can create custom helper.
You can create custom helper function by creating extensions method.In following code snippet I have created a SubmitButton html helper that generate submit button.



public static class HtmlHelpers
    {
        public static MvcHtmlString SubmitButton(this HtmlHelper helper, string text)
        {
            string str = "<input type=\"submit\" value=\"" + text + "\" />";
            return new MvcHtmlString(str);
        }
    }

How to use custom Helper

@Html.ToUpper("Submit")

Comments

Popular posts from this blog

How to get cell value of gridview using JQUERY

how to convert web page to pdf

Export Html to Pdf using iTextSharp(GridView)