Tuesday, November 26, 2013

How to enable html source button on tinyMCE?

Add "code" into plugins list, then add "code" into button array
        tinyMCE.init({
            // General options
            mode: "textareas",
            plugins: "spellchecker,code",
            theme : "advanced",
            theme_advanced_buttons1 : "bold,italic,underline,separator,strikethrough,justifyleft,justifycenter,justifyright,justifyfull,bullist,numlist,undo,redo,link,unlink,code",
            theme_advanced_buttons2 : "code",
        });

Weinre with Browserstack

http://arafat.azurewebsites.net/2013/11/16/weinre-on-azure-in-combination-with-browserstack/

Wednesday, November 20, 2013

How to implement minimum string length validation by Data annotation in ASP.NET MVC?

Two ways:
Fisrt:
        [StringLength(50, ErrorMessage = "The {0} must be at least {2} characters long.", MinimumLength = 10)]
 
Second:
Regular expression
[RegularExpression(@"^.{10,}$", ErrorMessage = "Minimum 10 characters required")]

Tuesday, November 19, 2013

How to set base URL in ASP.NET MVC for JavaScript?

In _Layout.cshtml, Add base tag in head, and pass base URL.

<head>
    <base href='@string.Format("{0}://{1}{2}", Request.Url.Scheme, Request.Url.Authority, Url.Content("~"))'/>
</head>