Friday, May 10, 2013

How to add static html in ASP.NET MVC site?

Need to change routing setting in Global.asax.cs file like following:

        public static void RegisterRoutes(RouteCollection routes)
        {
            routes.IgnoreRoute("{resource}.html/{*pathInfo}");
        }

Thursday, May 9, 2013

How to change URL without reloading current page by Javascript

window.history.pushState('page2', 'Title', '/page2');

Tuesday, May 7, 2013

What is the difference between Html button and input type=button?


Almost same, but button with more rendering abilities.


Buttons created with the BUTTON element function just like buttons created with the INPUT element, but they offer richer rendering possibilities: the BUTTON element may have content. For example, a BUTTON element that contains an image functions like and may resemble an INPUT element whose type is set to “image”, but the BUTTON element type allows content.
The Button Element - W3C

References:
http://stackoverflow.com/questions/469059/button-vs-input-type-button-which-to-use
http://web.archive.org/web/20110721191046/http://particletree.com/features/rediscovering-the-button-element/

Friday, May 3, 2013

How to extract text from html by HtmlAgilityPack?


            string htmlstring ="

adsasd

"; HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(htmlstring); foreach (var script in doc.DocumentNode.Descendants("script").ToArray()) script.Remove(); foreach (var style in doc.DocumentNode.Descendants("style").ToArray()) style.Remove(); string ExtractedText = doc.DocumentNode.InnerText;

How to change EDMX connection string at runtime in Entity Framework?

Call constructor with connection string parameter like:
var db = new dbContext(connectionstring);