Tuesday, December 24, 2013

Code First migration in asp.net MVC 4

Introduction: In this article I will explain how we can enable Code First migration in asp.net MVC 4

Description:

Migration is used to backup our database when we are going to develop application using code first approach in asp.net MVC.
I have a class named Student_Detail.cs in Models:
public class Student_Detail
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public string Subject { get; set; }
        public int Marks { get; set; }
    } 
Now I add a new property in this class for student address.

Thursday, December 19, 2013

Create, Read, Update and Delete in Asp.net MVC 4 using Code first approach

Introduction: In this article I will explain how we can Create, Read, Update and Delete in Asp.net with MVC 4 Razor view Engine using Entity framework with Code first approach.
MVC 4 Razor view Engine

Requirement:
I am using Visual studio 2012 to develop this project.

Description:

Add a MVC Project:

Tuesday, November 26, 2013

How to enable IIS on window 7 OR Installing the IIS on Window 7

Introduction: In this article I will explain how we can enable the IIS on window 7.
Description:

IIS stand for Internet Information Services. By default IIS is not enabled on window 7. To enable the IIS follow the below mention steps:
Step 1: click on start and then click on Control Panel.
IIS
(Click to enlarge)
Step 2: Control panel will be open and click on Programs and features.
IIS
(Click to enlarge)
Step 3: click on Turn windows features on or off.
IIS
(Click to enlarge)
Step 4: pop up window will be and take some time to load window features.
Step 5: In pop up windows features looks for IIS (Internet Information Services).
IIS
(Click to enlarge)
Step 6: select the IIS checkbox and hit the Ok button.
Step 7: now you see a progress indicator appears it would take some time for configuration. When the configuration complete windows dialog close itself.

IIS is now installed/enabled. To confirm installation is successful or not type the http://localhost/ on browser.
IIS
Default website

Sunday, November 17, 2013

What is Scaffolding in Asp.net MVC?

Introduction: in this article I will explain what is Scaffolding in Asp.net MVC.

Description:

Scaffolding is used by many software technologies. It’s a code generate framework in MVC application. Scaffolding provides as quick way to generate code for CRUD (Create, Read, update and Delete) in MVC application. Scaffolding is time saving to write code for application.

How to hide div element according to screen resolution

Introduction: in this article I am going explain how we can hide a div element according to screen resolution via CSS.

Sometimes we need to hides div element on screen resolution commonly used in responsive websites. Simple we can do it via media query.  Add the below given code in your stylesheet and define your resolution/width as you needed:

@media (min-width: 0px) and (max-width: 480px) {
.sidebar {  display: none; }
}

Thursday, November 14, 2013

HTTP Error 403.14 - Forbidden The Web server is configured to not list the contents of this directory.

Introduction: In this post I will explain how we can solve the “HTTP Error 403.14 – Forbidden The Web server is configured to not list the contents of this directory.” error when we run the website on IIS.
HTTP Error 403.14 - Forbidden

This error occurs when request URL and directory browsing is not enabled/configured. To solve this error follow the below given steps:
1.       Open IIS manager and select the website for which show the error.
2.       Double click on Directory browsing.

Tuesday, November 12, 2013

HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.

Introduction: In this post I am going to explain how we can solve the “HTTP Error 404.3 - Not Found The page you are requesting cannot be served because of the extension configuration. If the page is a script, add a handler. If the file should be downloaded, add a MIME map.” error when we run the website on IIS.
HTTP Error 404.3 - Not Found


To solve this error follow the below given steps:
11.      Open control panel and click on programs and features.
22.      Click on “turn windows features on or off “option.
33.      Pop up window will be open and look for IIS (internet information services).
44.     Expand the IIS.

Tuesday, October 29, 2013

How to create Contact Us page in Asp.net

Introduction: In this article I have explained how we can create contact us page in Asp,net.
Contact Us

Contact us page is a major part of websites through which users send comments, queries feedback etc. of website to admin/website owner.

Add a new webform to website. Drag and drop the Textbox, button, validation controls from Toolbox and desgin the .aspx page as shown below:
<table align="center">
    <tr><td><h1>Contact Us</h1></td><td></td></tr>
    <tr><td>Name:</td><td><asp:TextBox ID="txtname" runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="rfvName" runat="server"
                                        ControlToValidate="txtname" Display="None"
                                        ErrorMessage="Enter Name" EnableTheming="True"></asp:RequiredFieldValidator></td></tr>
     <tr><td>Email:</td><td><asp:TextBox ID="txtemail" runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="rfvrequireemail" runat="server"
                                        ControlToValidate="txtemail" Display="None"
                                        ErrorMessage="Enter Email" EnableTheming="True"></asp:RequiredFieldValidator>
         <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
             ControlToValidate="txtemail" ErrorMessage="Enter Valid Email"
             ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"></asp:RegularExpressionValidator>
         </td></tr>

Monday, October 14, 2013

How to integrate Captcha in asp.net

Introduction: In this article I have explained how we can integrate Captcha in asp.net.
Captcha

Captcha is mostly used in Sign up and contact us form. I use the Recaptcha library. You can download the Recaptcha library from given link:
After download the Recapctha library extract it. You see the option dll for 4.0 or 4.5 frameworks. Take new website, right click on your website and choose Add Reference as shown in snapshot: 
Captcha

Now click on browse and select the Recaptcha.web.dll. 
Captcha

You can also add the Captcha control to Toolbox. To use Captcha control you need a public and private key. To get the key go to below given link:

Saturday, October 12, 2013

Noble Prize 2013

Noble Prize in Physics:
The noble prize in physics was awarded jointly to Francois Englert of Belgium and Peter W. Higgs of England. Prize was awarded for their theory of how subatomic particles acquire their mass “for the theoretical discovery of a mechanism that contributes to our understanding of the origin of mass of subatomic particles, and which recently was confirmed through the discovery of the predicted fundamental particle, by the ATLAS and CMS experiments at CERN's Large Hadron Collider”.

Noble prize in Chemistry:
The noble prize in Chemistry was awarded jointly to three U.S. based Martin Karplus, Michael Levitt and Arieh Warshel. Prize was given for developing multiscale models for chemical systems. This model predicts the complex chemical reactions and that can be used for many purposes.

Thursday, October 10, 2013

HTTP Error 500.21 - Internal Server Error Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list

Introduction: In this post I will explain how we can sort out the “HTTP Error 500.21 - Internal Server Error Handler "PageHandlerFactory-Integrated" has a bad module "ManagedPipelineHandler" in its module list” error when we run the website on IIS.

To sort out this error Go to Start menu >> All programs >> Accessories >> Right click on Command Prompt >> Run as Administration and type below given command:

          %windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe –i

Is it helpful?

If yes post your comment to admire my work. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

Sunday, September 29, 2013

How to use SiteMapPath Navigation Control in Asp.net

Introduction: In this article I have explain How to use SiteMapPath Navigation Control in Asp.net



Description:

Right click on Project/Website name > Add New Item > Select Site Map as mention in attached snapshot: 


You see the structure as show below:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="" title=""  description="">
        <siteMapNode url="" title=""  description="" />
        <siteMapNode url="" title=""  description="" />
    </siteMapNode>
</siteMap>

Enter the .aspx page name in URL, Title and Description as shown in below example:
<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="Default.aspx" title="Home"  description="Home Page">
        <siteMapNode url="About_Us.aspx" title="About Us"  description="Aount Us Page" />
      <!--For Sub menu (Here Photo Gallery is Sub menu of Achievement Menu)-->
      <siteMapNode url="Achievements.aspx" title="Achievement" description="Achievements Page">
        <siteMapNode url="Photo_Gallery.aspx" title="Photo Gallery" description="Photo Gallery Page"/>
      </siteMapNode>
        <siteMapNode url="Contact_Us.aspx" title="Contact Us"  description="Contact Us Page" />
    </siteMapNode>
</siteMap>

Add a new webform to project. Drag and drop the control SiteMapPath from Toolbox> Navigation as show in attached snapshot:


After that you can change the formating of SiteMapPath via click on Auto Foramt, choose your style or can add the CssClass in Properties
  <asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana"
            Font-Size="0.8em" PathSeparator=" : ">
        <CurrentNodeStyle ForeColor="#333333" />
        <NodeStyle Font-Bold="True" ForeColor="#7C6F57" />
        <PathSeparatorStyle Font-Bold="True" ForeColor="#5D7B9D" />
        <RootNodeStyle Font-Bold="True" ForeColor="#5D7B9D" />
        </asp:SiteMapPath>

Run the project and check the result.

Is it helpful?

If yes post your comment to admire my work. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

Wednesday, September 25, 2013

Validate DropDownlist using Jquery in asp.net

Introduction: In this article I have explain how we can validate the DropDownlist using Jquery in asp.net.
Validate DropDownlist

Description:
Add a new webform to project. Drag and drop the DropDownlist and button controls from Toolbox. Desgin the .aspx page as shown below:
<table align="center">
    <tr><td>Known Language:</td><td><asp:DropDownList ID="ddllanguage" runat="server">
    <asp:ListItem Text="Select" Value="0" />
<asp:ListItem Text="English" Value="1" />
<asp:ListItem Text="Hindi" Value="2" />
<asp:ListItem Text="Punjabi" Value="3" />
<asp:ListItem Text="German" Value="4" />
    </asp:DropDownList></td></tr>
                        <tr>&nbsp;</tr>
                    <tr><td>&nbsp;</td><td>
                        <asp:Button ID="btnsubmit" runat="server" Text="Submit"/></td></tr>
    </table>

After that put the given Jquery in .aspx page between Head Tag:
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js">
</script>
<script type="text/javascript" language="javascript">
    $(document).ready(function () {
        $('#btnsubmit').click(function () {
            if ($("#ddllanguage").val() > 0) {
                return true;
            }
            else {
                alert('Please select Known Language')
                return false;
            }
        })
    });
</script>

Run the project and check out the result.

Is it helpful?

If yes post your comment to admire my work. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.

Friday, September 20, 2013

Store Password in Encrypted format to Database in asp.net

Introduction: In this article I have explain how we can insert the password in encrypted format to database.
 encrypted password

Description:

I created a Table USER_REGISTRATION:
ID
int
USERNAME
varchar(50)
PASSWORD
varchar(50)
FIRST_NAME
varchar(50)
LAST_NAME
varchar(50)
SEX
varchar(50)
PHONE
int
EMAIL_ID
varchar(50)

Here ID is autoincrement and primary key.
Add a webform to project. Drag and drop the controls Textbox, button from Toolbox and design the page show below:
<div class="form">
    <table>
    <tr><td>Username:-</td><td>
        <asp:TextBox ID="txtusername" runat="server"></asp:TextBox>
      

Tuesday, September 10, 2013

Auto refresh data in Gridview without loading whole page in asp.net

Introduction: In this post I will explain how we can Auto refresh data in Gridview without loading whole page in asp.net using ajax.
Auto refresh data in Gridview

Description:

Add a webform to project. Drag and drop the Gridview, Update Panel control from Toolbox and desgin the .aspx as shown below:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
    <script type="text/javascript" src="js/gridviewScroll.min.js"></script>
    <script type="text/javascript" src="js/scrollsaver.min.js"></script>
    <link href="css/GridviewScroll.css" rel="stylesheet" />
    <style type="text/css">
       BODY,TD
              {
                  font-family: ·L³n¥¿¶Ã‚Åé, Tahoma, Arial, Verdana;
                  font-weight: normal;
                  font-size: 14px;
                  color: #000;
              }
    </style>

Monday, September 9, 2013

Add Meta Tag Code behind in asp.net

Introduction: In this article I will expalin how we can Add Meta Tag Code behind in asp.net.
Description:

We need to add Meta tag code behind/Dynamically in application. Suppose in application we create Content pages from Master page but we want to add different page title, Title, Description and keyword for each page.
Add a new webform or create content page from master page. On .aspx.cs page write the mention code:
protected void Page_Load(object sender, EventArgs e)
    {
        //add meta tag dynamically
        Page.Title = "Enter Page Title";

        //add meta title
        HtmlMeta metatitle = new HtmlMeta();
        metatitle.Name = "Title";
        metatitle.Content = "Enter Meta Title";
        Page.Header.Controls.Add(metatitle);

        //add meta description
        HtmlMeta metadesc = new HtmlMeta();
        metadesc.Name = "description";
        metadesc.Content = "Enter Description";
        Page.Header.Controls.Add(metadesc);

        //add meta keywords
        HtmlMeta metakeyword = new HtmlMeta();
        metakeyword.Name = "keywords";
        metakeyword.Content = "Enter Keywords";
        Page.Header.Controls.Add(metakeyword);
    }

In VB (.aspx.vb)

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'add meta tag dynamically
        Page.Title = "Enter Page Title"

        'add meta title
        Dim metatitle As New HtmlMeta()
        metatitle.Name = "Title"
        metatitle.Content = "Enter Meta Title"
        Page.Header.Controls.Add(metatitle)

        'add meta description
        Dim metadesc As New HtmlMeta()
        metadesc.Name = "description"
        metadesc.Content = "Enter Description"
        Page.Header.Controls.Add(metadesc)

        'add meta keywords
        Dim metakeyword As New HtmlMeta()
        metakeyword.Name = "keywords"
        metakeyword.Content = "Enter Keywords"
        Page.Header.Controls.Add(metakeyword)

    End Sub
Run the project. To check Meta Tag right click on page>>View Page Source. See in Head tag Meta Tags are added to page.

Is it helpful?

If yes post your comment to admire my work. You can like me on Facebook, Google+, Linkedin and Twitter via hit on Follow us Button and also can get update follow by Email.