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.

Entries for the ‘asp.net’ Category

ASP.NET MVC 2 RC2 (Release Candidate 2) Released

ASP.NET MVC 2 is a framework for developing highly testable and maintainable Web applications by leveraging the Model-View-Controller (MVC) pattern. The framework encourages developers to maintain a clear separation of concerns among the responsibilities of the application – the UI logic using the view, user-input handling using the controller, and the domain logic using the model. ASP.NET MVC applications are easily testable using techniques such as test-driven development (TDD).
The installation package includes templates and tools for Visual Studio 2008 SP 1 to increase productivity when writing ASP.NET MVC applications. For example, the Add View dialog box takes advantage of customizable code generation (T4) templates to generate a view based on a model object. The default project template allows the developer to automatically hook up a unit-test project that is associated with the ASP.NET MVC application.
Because the ASP.NET MVC framework is built on ASP.NET 3.5 SP 1, developers can take advantage of existing ASP.NET features like authentication and authorization, profile settings, localization, and so on. Download it at: http://www.microsoft.com/downloads/details.aspx?FamilyID=7aba081a-19b9-44c4-a247-3882c8f749e3&displaylang=en

What is new:

  • The new ASP.NET MVC 2 validation feature now performs model-validation instead of input-validation (this means that when you use model binding all model properties are validated instead of just validations on changed values of a model).  This behavior change was based on extensive feedback from the community.
  • The new strongly-typed HTML input helpers now support lambda expressions which reference array or collection indexes.  This means you can now write code like Html.EditorFor(m=>m.Orders[i]) and have it correctly output an HTML <input> element whose “name” attribute contains the index (e.g. Orders[0] for the first element), and whose “value” contains the appropriate value.
  • The new templated Html.EditorFor() and Html.DisplayFor() helper methods now auto-scaffold simple properties (and do not render complex sub-properties by default).  This makes it easier to generate automatic scaffolded forms.  I’ll be covering this support in a future blog post.
  • The “id” attribute of client-script validation message elements is now cleaner.  With RC1 they had a form0_ prefix.  Now the id value is simply the input form element name postfixed with a validationMessage string (e.g. unitPrice_validationMessage).
  • The Html.ValidationSummary() helper method now takes an optional boolean parameter which enables you to control whether only model-level validation messages are rendered by it, or whether property level validation messages are rendered as well.  This provides you with more UI customization options for how validation messages are displayed within your UI.
  • The AccountController class created with the default ASP.NET MVC Web Application project template is cleaner.
  • Visual Studio now includes scaffolding support for Delete action methods within Controllers, as well as Delete views (I always found it odd that the default T4 templates didn’t support this before).
  • jQuery 1.4.1 is now included by default with new ASP.NET MVC 2 projects, along with a –vsdoc file that provides Visual Studio documentation intellisense for it.
  • The RC2 release has some significant performance tuning improvements (for example: the lambda based strongly-typed HTML helpers are now much faster).
  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

asp.net Interview: Can you explain the difference between an ADO.NET Dataset and an ADO Recordset

Can you explain the difference between an ADO.NET Dataset and an ADO Recordset?

  • You can store many edits in a DataSet, and write them to the original data source in a single operation. seo-job-interview
  • Though the DataSet is universal, other objects in ADO.NET come in different versions for different data sources.
  • There’s no concept of cursor types in a DataSet.
  • A DataSet is designed to work without any continuing connection to the original data source.
  • A DataSet can represent an entire relational database in memory, complete with tables, relations, and views.
  • Data in a DataSet is bulk-loaded, rather than being loaded on demand.
  • DataSets have no current record pointer You can use For Each loops to move through the data.
  • Digg
  • DZone
  • Yahoo Buzz
  • Delicious
  • Reddit
  • StumbleUpon
  • SmakNews
  • Jumptags
  • Ping
  • Share/Bookmark

Interview Questions on asp.net

  • Whats MSIL, and why should my developers need an appreciation of it if at all? MSIL is the Microsoft Intermediate Language. All .NET compatible languages will get converted to MSIL. asp.net-design-logo
  • Which method do you invoke on the DataAdapter control to load your generated dataset with data? The .Fill() method
  • Can you edit data in the Repeater control? No, it just reads the information from its data source
  • What base class do all Web Forms inherit from? The Page class.
  • Name two properties common in every validation control? ControlToValidate property and Text property.
  • What tags do you need to add within the asp:datagrid tags to bind columns manually? Set AutoGenerateColumns Property to false on the datagrid tag
  • How can you provide an alternating color scheme in a Repeater control? Use the AlternatingItemTemplate
  • What property must you set, and what method must you call in your code, in order to bind the data from some data source to the Repeater control? You must set the DataSource property and call the DataBind method.
  • What tag do you use to add a hyperlink column to the DataGrid? <asp:HyperLinkColumn>
  • What is the transport protocol you use to call a Web service? SOAP is the preferred protocol.
  • True or False: A Web service can only be written in .NET? False
  • What does WSDL stand for? (Web Services Description Language)
  • Explain what a diffgram is, and a good use for one? The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. For reading database data to an XML file to be sent to a Web Service.
  • Which template must you provide, in order to display data in a Repeater control? ItemTemplate
    • Digg
    • DZone
    • Yahoo Buzz
    • Delicious
    • Reddit
    • StumbleUpon
    • SmakNews
    • Jumptags
    • Ping
    • Share/Bookmark

    ASP.NET Interview Questions and Answers

    1. Explain the differences between Server-side and Client-side code?
    Server-side code executes on the server. Client-side code executes in the client’s browser.aspnet

    2. What type of code (server or client) is found in a Code-Behind class?
    Server-side code. Since code-behind is executed on the server. However, during the code-behind’s execution on the server, it can render client-side code such as JavaScript to be processed in the clients browser. But just to be clear, code-behind executes on the server, thus making it server-side code.

    3. Should user input data validation occur server-side or client-side?
    All user input data validation should occur on the server at a minimum. Additionally, client-side validation can be performed where deemed appropriate and feasable to provide a richer, more responsive experience for the user.

    4. What is the difference between Server.Transfer and Response.Redirect?
    Why would I choose one over the other? Server.Transfer transfers page processing from one page directly to the next page without making a round-trip back to the client’s browser. This provides a faster response with a little less overhead on the server. Server.Transfer does not update the clients url history list or current url. Response.Redirect is used to redirect the user’s browser to another page or site. This performas a trip back to the client where the client’s browser is redirected to the new page. The user’s browser history list is updated to reflect the new address.

    5. What is the Global.asax used for?
    The Global.asax (including the Global.asax.cs file) is used to implement application and session level events.

    6. What are the Application_Start and Session_Start subroutines used for?
    This is where you can set the specific variables for the Application and Session objects.

    7. Whats an assembly?
    Assemblies are the building blocks of the .NET framework.

    8. Can you explain what inheritance is and an example of when you might use it?
    When you want to inherit (use the functionality of) another class. Example: With a base class named Employee, a Manager class could be derived from the Employee base class.

    9. Describe the difference between inline and code behind.
    Inline code written along side the html in a page. Code-behind is code written in a separate file and referenced by the .aspx page.

    10. Explain what a diffgram is, and a good use for one?
    The DiffGram is one of the two XML formats that you can use to render DataSet object contents to XML. A good use is reading database data to an XML file to be sent to a Web Service.

    • Digg
    • DZone
    • Yahoo Buzz
    • Delicious
    • Reddit
    • StumbleUpon
    • SmakNews
    • Jumptags
    • Ping
    • Share/Bookmark

    jQuery 1.4 Released

    In celebration of jQuery’s 4th birthday, the jQuery team is pleased to release the latest major release of the jQuery JavaScript library! A lot of coding, testing, and documenting has gone into this release, and we’re really quite proud of it.

    You can feel free to include the above URL directly into your site and you will get the full performance benefits of a quickly-loading jQuery.

    With jQuery 1.4 we attempted to minimize any large upgrade hassles – maintaining the signatures of all public functions. That being said, please read through the list of potentially-breaking changes to be aware of what might cause problems in your applications.

    Features

    Below is an overview of all the changes and functionality added to jQuery 1.4. Additionally all of the changes have been documented in the jQuery 1.4 docs.

    And you can go jQuery.com to view the detail

    • Digg
    • DZone
    • Yahoo Buzz
    • Delicious
    • Reddit
    • StumbleUpon
    • SmakNews
    • Jumptags
    • Ping
    • Share/Bookmark

    Server Side Validation With ASP.NET MVC

    aspnet_mvc When you’re using ASP.NET MVC, there’s no validation controls for you compared to ASP.NET WebForms. It is always important to validate data on the server as well as the client. Back when Dynamic Data was being developed, a set of attributes was created to help tell the Dynamic Data folks about validation and other metadata so they could create smart scaffolds. What this allows you to do is decorate your classes or properties with validation attributes. A project that is available on CodePlex gives you the power to inject this validation into your MVC project. The CodePlex project can be found here. The end results are you can decorate your classes with some of the following attributes to perform server side validation:

    • Required – a required field
    • StringLength – allows you to set the minimum and maximum length of a string
    • RegularExpression – performs regular expression validation

    When you use this your validation classes will look like the following example:

    Via C#

       1: public class EmployeeMetaData

       2: {

       3: [Required]

       4:       [StringLength(10, ErrorMessage="Given name cannot be more than 10 characters")]

       5:       public string GivenName { get; set; }

       6:  

       7:       [Required]

       8:       public string Surname { get; set; }

       9: }

    Via VB

       1: Public Class EmployeeMetaData

       2: Private privateGivenName As String

       3: <Required, StringLength(10, ErrorMessage:="Given name cannot be more than 10 characters")> _

       4: Public Property GivenName() As String

       5:       Get

       6:             Return privateGivenName

       7:       End Get

       8:       Set(ByVal value As String)

       9:             privateGivenName = value

      10:       End Set

      11: End Property

      12:  

      13:        Private privateSurname As String

      14:        <Required> _

      15:        Public Property Surname() As String

      16:              Get

      17:                    Return privateSurname

      18:              End Get

      19:              Set(ByVal value As String)

      20:                    privateSurname = value

      21:              End Set

      22:        End Property

      23: End Class

    • Digg
    • DZone
    • Yahoo Buzz
    • Delicious
    • Reddit
    • StumbleUpon
    • SmakNews
    • Jumptags
    • Ping
    • Share/Bookmark