Jack @ ASP.NET

As a software engineer, I focus on .NET, especially asp.net, C#, WCF and so on, and I am also very interested in Search Engine Optimization.

Visual Studio LightSwitch

Microsoft Visual Studio LightSwitch helps you solve specific business needs by enabling you to quickly create professional-quality business applications, regardless of your development skills. LightSwitch is a new addition to the Visual Studio family. Visual Studio LightSwitch is designed to simplify and shorten the development of typical forms-over-data business applications.

Scenario: forms-over-data business
Advantages:

  •  simplify and shorten the development
  •  you do not need to know .net and etc.

The build-in starter kit
Customer Service
Application for managing customer accounts and invoices.

Expense Tracker
Application for creating and tracking expense reports.

Issue Tracker
Application for tracking issues logged to an IT helpdesk.

Job Candidate Tracker
Application for managing job applicants and open positions.

Performance Review
Application for tracking employee performance data.

Status Report
Application for tracking project updates and other statuses.

Time Tracker
Application for managing employee time entry.

HTML vs XHTML

HTML syntax is the format suggested for most authors. It is compatible with most legacy Web browsers. If a document is transmitted with an HTML MIME type, such as text/html, then it will be processed as an HTML document by Web browsers. This specification defines version 5 of the HTML syntax, known as “HTML5″.

XHTML syntax is an application of XML. When a document is transmitted with an XML MIME type, such as application/xhtml+xml, then it is treated as an XML document by Web browsers, to be parsed by an XML processor. Authors are reminded that the processing for XML and HTML differs; in particular, even minor syntax errors will prevent a document labeled as XML from being rendered fully, whereas they would be ignored in the HTML syntax. This specification defines version 5 of the XHTML syntax, known as “XHTML5″.

The DOM, the HTML syntax, and XML cannot all represent the same content. For example, namespaces cannot be represented using the HTML syntax, but they are supported in the DOM and in XML. Similarly, documents that use the noscript feature can be represented using the HTML syntax, but cannot be represented with the DOM or in XML. Comments that contain the string “–>” can only be represented in the DOM, not in the HTML and XML syntaxes.

The term MIME type is used to refer to what is sometimes called an Internet media type in protocol literature. The term media type in this specification is used to refer to the type of media intended for presentation, as used by the CSS specifications.

jQuery script to scroll to the top of window

$('html, body').animate({ scrollTop: 0 }, 'slow');

Call web service via jQuery in asp.net

step 1. Add Web service, and you must add a [System.Web.Script.Services.ScriptService] to the service class

(in webservice.asmx.cs file)

   1: /// <summary>

   2: /// Summary description for WebService1

   3: /// </summary>

   4: [WebService(Namespace = "http://tempuri.org/")]

   5: [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]

   6: [System.ComponentModel.ToolboxItem(false)]

   7: // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 

   8: [System.Web.Script.Services.ScriptService]

   9: public class WebService1 : System.Web.Services.WebService

  10: {

  11:     [WebMethod]

  12:     public string DeleteProduct(string id)

  13:     {

  14:         Thread.Sleep(800);

  15:         return "Hello World22: " + id;

  16:     }

  17: }

step 2. call webservice in aspx via jQuery

(in head of the page)

   1: <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>

   2: <script type="text/javascript">

   3:     $(function () {

   4:         $('a').click(function () {

   5:             deleteProduct(111);

   6:         }); // end of  $('a').click(function () {

   7:  

   8:     });     // end of $(function () {

   9:  

  10:  

  11:  

  12:     function deleteProduct(id) {

  13:         $.ajax({

  14:             type: "POST",

  15:             url: "WebService1.asmx/DeleteProduct",

  16:             data: "{id: '" + id.toString() + "'}",

  17:             contentType: "application/json; charset=utf-8",

  18:             dataType: "json",

  19:             success: function (msg) {

  20:                 AjaxSucceeded(msg);

  21:             },

  22:             error: AjaxFailed

  23:         });

  24:     }

  25:     function AjaxSucceeded(result) {

  26:         alert(result.d);

  27:     }

  28:     function AjaxFailed(result) {

  29:         alert(result.status + ' - ' + result.statusText);

  30:     }  

  31: </script>

Web Essentials extension – Visual Studio 2010 add-on

The Web Essentials extension lets you perform common tasks much easier,

Features include:

  • Minify CSS
  • Same word highlighting
  • Code collapsing/outlining
  • Convert easily between hex, rgb and named color values
  • Right-click folder now includes Add JavaScript and Stylesheets
  • Adds SmartTags to selectors for targeting specific IE versions
  • Color preview on mouse hover
  • Font preview on mouse hover
  • Image preview on mouse hover
  • Support for regions /*#region MyRegion */
  • Brace matching
  • Minify JavaScript
  • Adds SmartTags to properties for targeting IE6 & IE7
  • Embed url() references as base64 strings
  • Drag and drop support for image, font, audio and video files

Download at http://visualstudiogallery.msdn.microsoft.com/6ed4c78f-a23e-49ad-b5fd-369af0c2107f

Use HttpRuntime.Cache to call asp.net Cache

In some scenario, you can’t visit asp.net cache, even via HttpContext.Current.Cache. For example, in Unit Test mode. In this case, you can use the HttpRuntime.Cache to access asp.net Cache.