Thursday, April 19, 2012

Web Performance Best Practices and Rules By Yahoo DEVELOPER Team

Yahoo!'s Exceptional Performance team has identified 34 rules that affect web page performance. YSlow's web page analysis is based on the 23 of these 34 rules that are testable. Click each performance rule below to see the details.
  1. Minimize HTTP Requests
  2. Use a Content Delivery Network
  3. Avoid empty src or href
  4. Add an Expires or a Cache-Control Header
  5. Gzip Components
  6. Put StyleSheets at the Top

Object cannot be cast from DBNull to other types. How to resolve this Exception Message?

Error Message: Object cannot be cast from DBNull to other types.

Solution: This exception occurred because the data type of data column of data row accepts null values, but the data type in C# not. All the data type that are "value types" (struct) don´t accepts null values.

Wednesday, April 18, 2012

Maximum SharePoint Content DB Capacity

100GB is not the limit, its actually a best practise. This post lists out few suggestions. The following represents Microsoft's guidance and best practices on content databases, as specified in various places on technet.microsoft.com:

  1. Limit the content database size to 100GB; use multiple content databases if necessary.
  2. Create multiple data files and spread them across multiple disks; only create files in the primary file group.
  3. The number of data files should be less than or equal to the number of core CPUs; count dual core processors as two CPUs; count each processor that supports hyper-threading as one CPU.

Tuesday, April 17, 2012

JQuery Autocomplete Key/Value

This solution with key/value with cascading Auto complete with web service.

This JQuery Script

<script type="text/javascript"> 
    $(document).ready(function () { 
      $("[id$='txRequesterName']").attr('disabled', true); 
      $("[id$='txAssetName']").attr('disabled', true); 
      $("[id$='txCompanyName']").autocomplete({ 
        source: function (request, response) { 
          $.ajax({ 
            type: "POST", 
            url: "WebService.asmx/GetCompany", 
            dataType: "json", 
            data: "{\"companyName\":\"" + request.term + "\"}", 
            contentType: "application/json; charset=utf-8", 
            success: function (data) { 
              response($.map(eval(data.d), function (item) { 
                return { 
                  label: item.label, 
                  value: item.label, 
                  id: item.value 
                } 
              })); 
            } 
          }) 
        }, 
        minLength: 1, 
        select: function (event, ui) { 
          $("[id$='txCompanyID']").val(ui.item.id); 
          $("[id$='txRequesterName']").attr('disabled', false); 
        }, 
        change: function (event, ui) { 
          $("[id$='txRequesterName']").val(''); 
          $("[id$='txRequesterName']").attr('disabled', false); 
        } 
      }); 

Sunday, April 15, 2012

Differences between value type and reference type?


Value Type Reference Type
Value type variable directly contain value itself. Reference type variable contain the address of object where the values are placed in memory. Or we can say they store the reference to object.
All value types are implicitly derived from System.ValueType. They are derived from System.Object class.
They doesn’t support inheritance. Means they are sealed implicitly. They can be inherited. They are internal by default.
A value type variable can’t be assigned value null. An object can have value null.
They can be declared without new operator. They can’t be declared without new operator.

Differentiate between Structure and Class in .net?

                        Structure

                           Class

Structures are value type, i.e. variable of struct type directly contain the data of structure

Classes are reference type, i.e variable of class (known as object) contain the reference to data.

Do not require, urgently, new operator to do its instantiation. Or instantiation can be done without new operator.

Do require new operator to do instantiation.

Each variable will have its own set of data even if they have same values.

More than one object can have reference to same data.

Default Value of a struct type can’t be null.

Default value of an Object of a class type is null.

Friday, April 13, 2012

What is the difference between HTTP-Post and HTTP-Get?

There are two common ways to pass data from one page to another, using http Get and Post methods. In Get method, data passed to server using URL encoding. So with Get method data added in URL as query string.

As their names imply, both HTTP GET and HTTP POST use HTTP as their underlying protocol. Both of these methods encode request parameters as name/value pairs in the HTTP request.
The GET method creates a query string and appends it to the script's URL on the server that handles the request.
The POST method creates a name/value pairs that are passed in the body of the HTTP request message.

What is Globalization? What are the steps to follow to get user's culture at run time?

What is Globalization?
Globalization is the process of creating an application that meets the needs of users from multiple cultures. This process involves translating the user interface elements of an application into multiple languages, using the correct currency, date and time format, calendar, writing direction, sorting rules, and other issues. Accommodating these cultural differences in an application is called localization.
The Microsoft .NET Framework simplifies localization tasks substantially by making its formatting, date/time, sorting, and other classes culturally aware. Using classes from the System.Globalization namespace, you can set the application’s current culture, and much of the work is done automatically!

What are the 3 different ways to globalize web applications?

Detect and redirect approach : In this approach we create a separate Web application for each supported culture, and then detect the user’s culture and redirect the request to the appropriate application. This approach is best for applications with lots of text content that requires translation and few executable components.
Run-time adjustment approach : In this approach we create a single Web application that detects the user’s culture and adjusts output at run time using format specifiers and other tools. This approach is best for simple applications that present limited amounts of content.
Satellite assemblies approach : In this approach we create a single Web application that stores culture-dependent strings in resource files that are compiled into satellite assemblies. At run time, detect the user’s culture and load strings from the appropriate assembly. This approach is best for applications that generate content at run time or that have large executable components.

Thursday, April 12, 2012

What are Cascading style sheets? What is the use of Style Builder?

What are the 2 ways provided by ASP.NET to format output in a Web application?
1. Use cascading style sheets (CSS) to control the appearance of elements on a Web form.These styles can set the color, size, font, and behavior of the HTML elements on a Web page.
2. Use Extensible Stylesheet Language Transformations (XSLT) to convert information from an Extensible Markup Language (XML) file to HTML output and position that information on a Web form. XSLT puts data from the XML file into HTML elements and applies styles to those elements.

What are Cascading style sheets?

Cascading style sheets (CSS) collect and organize all of the formatting information applied to HTML elements on a Web form. Because they keep this information in a single location, style sheets make it easy to adjust the appearance of Web applications.

Tuesday, April 10, 2012

What is ViewState? What are the performance implications of ViewState?

What is ViewState?
Web forms have very short lifetimes.In ASP.NET, the data that is entered in controls is encoded and stored in a hidden field. This encoded data is then sent with each request and restored to controls in Page_Init. The data in these controls is then available in the Page_Load event.The data that ASP.NET preserves between requests is called the Web form’s view state.

How do you enable or disable a ViewState for a control on the page?

Every ASP.NET control has a property called EnableViewState. If EnableViewState is set to true ViewState is enabled for the control. If EnableViewState is set to false ViewState is disabled for the control.

How do you enable or disable a ViewState at the page level?

At the page level you can enable or disable ViewState using EnableViewState property of the page.

Monday, April 9, 2012

What are ASP.NET Validation controls? What is a validation group?

What are ASP.NET Validation controls?
ASP.NET provides validation controls to help you check Web form data entries before the data is accepted and saved in the Database. Validation controls can be used to address the following questions.
1. Did the user enter anything?
2. Is the entry the appropriate kind of data (For example, Date of Birth should be a valid Date, Name should be a string etc.)?
3. Is the data within a required range?(For example age cannot be greater than 100 years)
The validation controls check the validity of data entered in associated server controls on the client before the page is posted back to the server.Most validity problems can be caught and corrected by the user without a round-trip to the server.

Where do the ASP.NET validation controls validate data, on the Client or on the Web Server?

ASP.NET validation controls validate data first on the client and then on the web server. If a client disables javascript on the browser then, client side validations are bypassed and validations are performed on the web server.

What are the steps involved in using a transaction object in ADO.NET?

What are the steps involved in using a transaction object in ADO.NET?
1.Open a database connection.
2.Create the transaction object using the database connection object’s BeginTransaction method.
3.Create command objects to track with this transaction, assigning the Transaction property of each command object to the name of the transaction object created in step 2.
4.Execute the commands. Because the purpose of transaction processing is to detect and correct errors before data is written to the database, this is usually done as part of an error-handling structure.
5.Commit the changes to the database or restore the database state, depending on the success of the commands.
Close the database connection.

Sunday, April 8, 2012

What is a transaction? How DataSets provide transaction processing?

What is a transaction?
Answer: A transaction is a group of commands that change the data stored in a database. The transaction, which is treated as a single unit, assures that the commands are handled in an all-or-nothing fashion. if one of the commands fails, all of the commands fail, and any data that was written to the database by the commands is backed out. In this way, transactions maintain the integrity of data in a database. ADO.NET lets you group database operations into transactions.

What is the main purpose of database transactions?
Answer: The main purpose of database transactions is to maintain the integrity of data in a database.

What is Tracing and what are the advantages of using tracing to log exceptions?

What is Tracing and what are the advantages of using tracing to log exceptions?
Answer: Tracing is a technique for recording events, such as exceptions, in an application. There have always been ways to record errors in an application - usually by opening a file and writing error messages to it. But tracing offers the following significant advantages:
Standardization:Building tracing into the .NET Framework ensures that programming techniques are the same across all the applications you develop with the .NET Framework.
Built-in Web support:ASP.NET extends the .NET Framework tools by including information related to the performance and behavior of Web requests.
Configuration:You can turn tracing on and off using settings in your application’s configuration file. You don’t have to recompile your application to enable or disable tracing.
Performance:While disabled, tracing statements do not affect application performance.

Saturday, April 7, 2012

How do map .htm and .html files to the ASP.NET executable using the IIS snap-in?

Answer: To map .htm and .html files to the ASP.NET executable using the IIS snap-in, follow these steps:
1. In the IIS snap-in, select the folder containing your Web application, and then choose Properties from the Action menu. IIS displays the Properties dialog box.
2. Click the Home Directory or Virtual Directory tab, and then click Configuration. IIS displays the Application Configuration dialog box, as shown in the diagram below.

Friday, April 6, 2012

TIPS - Increase SQL Server stored procedure performance

a) Define / Use of variables within stored procedure

b) Use of uncommon values in parameter values on the first execution after a stored proc is created/recompiled, resulting in a bad query plan chosen by the optimizer.

c) Join order. What's an inner and outer table. What is nested join and/or merge join. And understand how the optimizer chooses the join order.

Thursday, April 5, 2012

User Defined Functions and Stored Procedures

  1. UDF are simpler to invoke than Stored Procedures from inside another SQL statement. They are Complex to Invoke.
  2. SQL functions that return non-deterministic values are not allowed to be called from inside User Defined Functions. GETDATE is an example of a non-deterministic function. Every time the function is called, a different value is returned. Therefore, GETDATE cannot be called from inside a UDF you create, but could not be used inside the function itself. Non-deterministic values are not allowed to be called from inside Stored Procedure.
  3. The User Defined Function must be prefaced with the owner name, DBO in this case. Not mandatory.