TipsOnLips.net

Your .net tips and tricks source

About the author

Author Name is someone.
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2010


Reset Button The ASP.NET MVC Style

There are many ways to reset a form in MVC including:

  1. Using a Form Reset Button.
  2. Using JavaScript or JQuery to reset a form.

My favorite option is a different one as option 1 only resets input fields and not grids, also it does not work after the form is submitted and the field is bound to a model. Option 2 needs some plumbing for each form.

My favorite option is as below which resets the form without a lot of effort:

 <input  type="button"  class="button"  value="Reset"  name="Reset"  
onclick="document.location.href =' <%  :  Url.Action("YourGetActionMethod")  %>'"  />
 

Categories: .Net Framework | C# | HTML | JavaScript | MVC
Posted by developer on Friday, August 20, 2010 10:44 PM
Permalink | Comments (0) | Post RSSRSS comment feed

ASP.NET: How to return a PDF file in MVC

For a PDF file to be returned as an action response in MVC 2, we have two options:

 1)    Either;

         public  ActionResult  GetMyPdfAsFile()
         {
             return  File(Url.Content("~/Content/Files/PDFs/MyPdf.pdf" ), "application/pdf" );
         }

2)     or;

         public  FileStreamResult  ShowMyPdf()
         {
             string  filePath = Server.MapPath("/Content/Files/PDFs/MyPdf.pdf" );
             byte [] pdf = System.IO.File .ReadAllBytes(filePath);
             MemoryStream  stream = new  MemoryStream (pdf, 0, pdf.Length);
             return  new  FileStreamResult (stream, "application/pdf" );
         }

Categories: ASP.NET | CSS | HTML | MVC
Posted by developer on Tuesday, August 03, 2010 8:25 PM
Permalink | Comments (0) | Post RSSRSS comment feed

Get Number Of DOM Elements using JavaScript

The number of DOM elements is easy to test, just type in Firebug's console:
document.getElementsByTagName('*').length

Other sources: http://getfirebug.com/console.html

Categories: HTML
Posted by developer on Tuesday, October 20, 2009 10:59 PM
Permalink | Comments (1) | Post RSSRSS comment feed

HTML Resources

  1. HTML and CSS Table Border Style Wizard
  2. 30 HTML Best Practices for Beginners

Categories: HTML
Posted by developer on Wednesday, April 22, 2009 10:30 AM
Permalink | Comments (0) | Post RSSRSS comment feed