Tuesday, 13 January 2015

ASP.NET 4.0 Features

Listing all Asp.NET 4.0 Features

In all interviews, asking about features which are released in (2.0/3/0/3.5/4/0/4.5) versions. But now i will explain the features only for 4.0 in this post.

Listing all the 4.0 features in category wise below ,

ASP.NET Core Services

1. Refactoring Web.Config

2. Extensible Output Caching

3. Auto-Start Web Applications

4. Permanently Redirecting a Page

5. Session State Compression

6. Expanding the Range of allowable URL's

Extensible Request Validation

1. Object caching and Object Caching Extensibility

2. Extensible HTML, URL and HTTP Header Encoding

3. Performance Monitoring for Individual applications in a single worker process

4. jquery Included  with webforms and MVC

5. Content Delivery Network Support

6. ScriptManager Explicit Scripts

ASP.NET Web Forms

1. Setting Meta Tags with the Page.MetaKeywords and Page.MetaDescription Properties

2. Enabling ViewState for Individual Controls.

3. Support for recently introduced browser and devices

4. A New way to define browser capabilities

5. Routing in ASP.NET 4

6. Setting ClientId's

7. Persisting Row Selection in Data Controls

8. FormView Control Enhancements

9. ListView Control Enhancements

10. Filtering Data with QueryExtender Control.

11. Enhanced support for web standards and accessbility

Project Template Changes

ASP.NET 4 introduced two new templates for both Web Application and WebSite projects.

1.  Empty
2. Non-Empty

In Empty template,similar to web site layout which already having earlier versions except contain web.config file that specified target version of .NET framework

In Non-Empty template, having created many files which are not available in earlier versions. It includes master page,css,html, ajax and member ship related codes For reference to developer how build the application with the structure.

Dynamic Data

1. Enabling Dynamic Data for Individual Data-Bound Controls in Existing Web Applications

2. Declarative DynamicDataManager Control Syntax.

3. Entity Templates.

4. New Field Templates for URLs and E-mail Addresses

5. Creating Links with the DynamicHyperLink Control

6. Support for Inheritance in the Data Model

7. Support for Many-to-Many Relationships (Entity Framework Only)

8. New Attributes to Control Display and Support Enumerations

9. Enhanced Support for Filters


Here, i am not elaborate each feature in detail, if you want to know elaborate each feature  then click on the below link,

http://msdn.microsoft.com/en-us/library/vstudio/s57a598e%28v=vs.100%29.aspx


That's it,

Happy Coding :)


Difference between Web Application and WebSites?

Most of the developers are confused on Web Application and WebSite options provided in ASP.NET for developing a new site. Even i also confused at initial stage.

Now i will explain some differences between web application & web site with my experience, By this to get some idea when to choose web application and web sites.

Real time example describes about Web Sites and Web Applications

Website - Providing information about sites (i.e., No Interaction by user)

Web Application - Along with information and also user can interactive with operations/functionality provided by site.

Differences

Web Application Web Site
Place all code files (.cs/.vb) in application folder structure and its pre-compiled into single dll.
i.e., one dll for all code files
 Place all code files(.cs/.vb) in App_Code folder and compiled into several dlls at runtime.i.e., several dlls for each code file.
Only one progrmming language  Create multi programming language in one website
i.e., one page using c# and another page created using vb.net
 Create automatically .csproj/.vbproj files(i.e., Include all files in the project and any references)No .csproj/.vbproj files
Pre-compile the site before deploymentNo need to compile the site before deployment
Only .aspx files need to deploy because pre-compiled dll's contain all details. Here we upload both .aspx and code behind files
If any changes in code need to re-compile the entire site
i.e., build/rebuild/clean the solution
 Upload only updated files instead of entire site.

These are the basic differences between Web Application and Web Site and i hope this will helpful to get an idea.

That's it,

Happy Coding:)

Monday, 29 December 2014

Compare Validator creating at codebehind in c#

Compare Validator is one of the validator control in ASP.NET validators. With this,we can use to compare the controls with the help of operator and type attributes.

Listing all Types of CompareValidator

  • Currency
  • Date
  • Double
  • Integer
  • String

Listing all Operators of CompareValidator

  • DateTypeCheck
  • Equal
  • GreaterThan
  • GreaterThanEqual
  • NotEqual
  • LessThan
  • LessThanEqual

Now we can see the below example code created in code behind and used for validating the fields,

            CompareValidator cmpval = new CompareValidator();
            cmpval.ControlToCompare = FromDate.ClientID;
            cmpval.ControlToValidate = ToDate.ClientID;
            cmpval.Type = ValidationDataType.Date;
            cmpval.Operator = ValidationCompareOperator.GreaterThanEqual;
            cmpval.ForeColor = Color.Red;
            cmpval.Display = ValidatorDisplay.Dynamic;
            cmpval.ErrorMessage = "From Date should be smaller than the To Date";
            plholdervalidmessage.Controls.Add(cmpval);

Adding the above example control to Placeholder

That's it,

Happy Coding:)              

ASP.NET URL Routing to MVC format

This is very useful post because if user want to show the url like in below format then how your going to show the below format using ASP.NET

ASP.NET URL : http://localhost/view.aspx?paramtype&param1=value&param2=value&...

ASP.NET MVC : http://localhost/view?paramtype&param1=value&param2=value&...

In order to achieve the MVC Url format using ASP.NET WebForms existing project then go with URL Routing. For this we need the following namespace,

System.Web.Routing

I am going to tell in step by step manner,

Step 1 : First add the System.Web.Routing namespace to project using Add Reference.

Step 2 : Add the following line in Web.Config file, under 
<system.web>
 <compilation defaultLanguage="c#" debug="true">
      <assemblies>
.... 
....

<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />     
 </assemblies>
    </compilation>
</system.web>

Step 3 : Add namespace  System.Web.Routing in Global.asax,cs file

Step 4 :  Call the method RegisterRoutes in Application_Start event

 protected void Application_Start(object sender, EventArgs e)
        {           
            RegisterRoutes(RouteTable.Routes);
        }

Step 5 : Create the event and route the MVC format
 private void RegisterRoutes(RouteCollection routes)
        {
                    routes.MapPageRoute("View", "view/{*extrainfo}", "~/view.aspx", true);
        }

Where, 1st Parameter - Name for routing
2nd parameter : Format for MVC
3rd Parameter - actual page.
4th Parameter - Set to true for routing


That's it,

Happy Coding :)          

Jquery important events

Here the below are jquery events which we are using regular basis and i list all the things in one place,So this, we reduce time for you to get the thing for your requirement. I hope this will help you to fix the issues,

- Text controls

$('input:text[id="textboxTheaterContent"]').val() - Reading
$('input:text[id="textDepFrom"]').val(""); - Setting

- Hidden
$('input:hidden[name="cmbPayerName"]').val();

- Get the text
 $('#ddlType :selected').text()

- Disable the control
 $("#buttonFileUpload").prop("disabled", true);

- Hide/Show the control
 $('#DivImageOwnerSelectionOptions').hide();
 $('#DivImageOwnerSelectionOptions').show();

- Focus
$('input:text[id="textDepFrom"]').focus();

- Check Numeric
$.isNumeric(elementboxowner)

Restrict <,>,~,^,\,? characters in ASP.NET Controls


This is very helpful post for all developers belongs to AJAX with any other technologies like ASP>NET,JAVA,....


In some scenarios, user don't want to allow some special characters in TextBox or input controls then we use AJAX FilteredTextBoxExtender control.


Restricted Special characters are <,>,~,^,\,?

Ex : We used Asp.Net Textbox control and add my control id to FilteredTextBoxExtender for reference

 <asp:TextBox ID="txtboxOwnerContent" runat="server" Height="18px" Width="302.5px"
                        MaxLength="150" CssClass="bordercolor defaultfontname" />
                    <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" FilterType="Custom"
                        FilterMode="InvalidChars" InvalidChars="<,>,~,^,\,?" TargetControlID="txtboxOwnerContent" />


With the above example,user can't able to type those characters.


That's it,

Happy Coding :)

Adding new CSS Class to existing CSS Class using Jquery

If user want to add/append one more style to existing CSS then  we used the following method

Jquery is a javascript library (i.e., Enhanced library of Javascript) with this we use the following method to add new CSS class to existing one.


Ex : $(".existingone").addClass("newone");


And also we can remove the existing style to particular control using the following way,

       $('.classname').attr("style", "");
       Remove styles to the existing one


That's It,


Happy Coding:)