Sunday, December 24, 2017

Upload file’s on button click using Dropzone JS plugin in asp.net application

In this article I am going how to upload file’s on button click using Dropzone JS plugin in asp.net application.

Description:
I want to upload multiple files using select or drag & drop in asp.net application on submit button click. I am using Dropzone js to upload file.

Implementation:
I have created a table GalleryImages to save file’s name and path.

Id
int
Filename
varchar(MAX)
FilePath
varchar(MAX)
Is_Deleted
bit

Create procedure to save detail to database table.

Monday, December 11, 2017

How to send email with attachment using Gmail SMTP from asp.net MVC application

In this article I am going to explain how to send email with attachment using Gmail SMTP from asp.net MVC application.

Description:
I want to send email with attachment using Gmail account.

Implementation:
Open the web.config file of project. Set key in Appsettings. After that mailsettings as shown below:
<appSettings>
    <add key="Email" value="Emailaddress@gmail.com"/>
  </appSettings>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network enableSsl="true" port="587" host="smtp.gmail.com" userName=" Emailaddress@gmail.com" password="password"/>
      </smtp>
    </mailSettings>
  </system.net>

Sunday, December 3, 2017

MVC : Send email with attachment

In this article I am going to explain how to send email with attachment using Gmail account in MVC application.

Description:
I want to send email with attachment using Gmail account.

Implementation:

Open the web.config file of project. Set key in Appsettings. After that mailsettings as shown below:
<appSettings>
    <add key="Email" value="Emailaddress@gmail.com"/>
  </appSettings>
  <system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network enableSsl="true" port="587" host="smtp.gmail.com" userName=" Emailaddress@gmail.com" password="password"/>
      </smtp>
    </mailSettings>
  </system.net> 

Wednesday, November 29, 2017

ASP.NET : Lock user for day after 3 invalid login attempt

In this article I am going to explain how to lock the user for day after 3 invalid login attempt in asp.net.

Description:
I want to lock the users for a day after 3 invalid login attempt. For example if user try to login on 25 November with 3 wrong password attempt, he/she will be locked for 25 November. He/she can’t login even enter correct password. He will be able to login on 26 November.  

Implementation:
I have created a table user_login


ASP.NET : Lock user for  day after 3 invalid login attempt

Saturday, November 25, 2017

MVC : Show confirmation message before submit, update or delete record

In this article I am going to explain how to show confirmation message before submit, update or delete record in MVC.

Description:
I want to show a confirmation message before perform any task like submit, update or delete the data. To implement this functionality you have to set onclick action of button or actionlink.

Implementation:
You have two different ways to implement this. First simply on button or actionlink use confirm as shown below:
<input type="submit" value="Create" onclick="return confirm('Are you sure want to create user?')" />       

Second using Jquery. Create Jquery function and call that on Onclick event as shown below:
<script>
    function Confirmmessage() {
        var alert = confirm("Are you sure want to create user?");
        if (alert) {
            return true;
        } else {
            return false;
        }
    }
</script>
Button:
<input type="submit" value="Create" onclick="return Confirmmessage()" />

I have create working example of create users for application.
Model (Login.cs)

How to send email from asp.net MVC application using web.config

In this article I am going to explain how to send email from asp.net MVC application using web.config
. 
Description:
If you don’t have SMTP server to send email then you can use Gmail smtp server to send email from your MVC application. To send email from web.config file you have to            set appsetting.
  
Implementation:
Open the web.config file of project. Set key in appsettings. After that mailsettings as shown below:

Sunday, November 19, 2017

MVC : Send email using Gmail account

In this article I am going to explain how to send email using Gmail account in asp.net MVC.

Description:
If you don’t have SMTP server to send email then you can use Gmail smtp server to send email from your MVC application.
  
Implementation:
Open the web.config file of project. Set key in appsettings. After that mailsettings as shown below:

Sunday, November 12, 2017

How to show confirmation message in MVC

In this article I am going to explain how to show confirmation message in MVC.

Description:
I want to show a confirmation message before perform any task like submit, update or delete the data. To implement this functionality you have to set onclick action of button or actionlink.

Implementation:
You have two different ways to implement this. First simply on button or actionlink use confirm as shown below:

<input type="submit" value="Create" onclick="return confirm('Are you sure want to create user?')" />  
   
Second using Jquery. Create Jquery function and call that on Onclick event as shown below:

<script>
    function Confirmmessage() {
        var alert = confirm("Are you sure want to create user?");
        if (alert) {
            return true;
        } else {
            return false;
        }
    }
</script>

Button:
<input type="submit" value="Create" onclick="return Confirmmessage()" />

I have create working example of create users for application.

Model (Login.cs)

Thursday, November 9, 2017

[Solved]: [Provided: Named Pipes Provider, error: 40- Could not open a connection to the SQL Server (Microsoft SQL Server, Error: 2)]

In this article I am going to explain how to resolve the Error: [Provided: Named Pipes Provider, error: 40- Could not open a connection to the SQL Server (Microsoft SQL Server, Error: 2)]

Description:
When I am trying to connect the Sql server, got an error:

Sunday, November 5, 2017

How to show message in popup in asp.net MVC

In this article I am going to explain how to show message in popup in asp.net MVC.

Description:
I want to show success message in popup after submit the data. We can show message in popup using jquery or HTML raw.

Implementation:
I have create a class Login to create users. When user created successfully show success message in popup.

Model (Login.cs)

Monday, October 30, 2017

Display number of records per page in MVC

In this article I am going to explain how to Display number of records per page in asp.net MVC.

Description:
I am using Pagedlist.mvc package for pagination. I want to show number of records are showing per page. For example you have 100 records and page size is 10. When you are at page 1 show in footer Showing 1-10 of 100 and on page 2 Showing 11-20 of 100.

Implementation:
Model (Employee.cs)

Sunday, October 29, 2017

MVC : Compare password and confirm password

In this article I am going to explain how to compare password and confirm password in asp.net MVC.

Description:
When creating users in MVC application want users to enter strong password and re-enter password to confirm.
  
Implementation:
  
Model

Saturday, October 28, 2017

How to change page size using dropdownlist in asp.net MVC

In this article I am going to explain how to change page size using dropdownlist in asp.net MVC.

Description:
I am using Pagedlist.mvc package for pagination. In previous article I have explained How to customize the pager in MVC Pagedlist.  Now I want to change/set page size using dropdownlist in foreach loop.

Implementation:
I want to display list of employees.
Model (Employee.cs)

[Solved]: Error:40–could not open a connection to SQL server

In this article I am going to explain how to resolve the Error: 40 – could not open a connection to SQL server.

Description:
When I am trying to connect the Sql server, got an error:

Cannot connect to localhost. :
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that the SQL Server is configured to allow remote connections. (provided: Named Pipes Provider, error: 40- Could not open a connection to the SQL Server) (Microsoft SQL Server, Error: 2).

Friday, October 27, 2017

How to validate strong password in asp.net MVC

In this article I am going to explain how to validate strong password in asp.net MVC. 

Description:
Password ensure the security for confidential information/data which is stored on your system or online anywhere. If you use weak password, it allow hackers to get access easily. So we have to always force users to set strong password. In strong password user must one uppercase, one lowercase, one special and one numeric (number) character.


Implementations:
I am going to create users for application.

Friday, October 6, 2017

Custom Pager in MVC Pagedlist

In this article I am going to explain how to customize the pager in MVC Pagedlist.

Description:
I want to show total number of records and number records are showing out of total records. Change the pagesize using dropdown.

Implementation:

Model
  public partial class Employee
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public Nullable<int> Phone { get; set; }
        public Nullable<int> Salary { get; set; }
        public string Department { get; set; }
        public string ImagePath { get; set; }
        public string EmailId { get; set; }
    }

Saturday, September 30, 2017

ASP.NET MVC : Change page size with dropdown

In this article I am going to explain how to change page size with dropdown in asp.net MVC.

Description:
I am using Pagedlist.mvc package for pagination. In previous article I have explained  .  Now I want to change/set page size using dropdown in foreach loop.

Implementation:
I want to display list of employees.

Model (Employee.cs)
    public partial class Employee
    {
        public int Id { get; set; }
        public string Name { get; set; }
        public Nullable<int> Phone { get; set; }
        public Nullable<int> Salary { get; set; }
        public string Department { get; set; }
        public string ImagePath { get; set; }
        public string EmailId { get; set; }
    }

Add controller
Now add an empty controller to project. Create action to fetch the data.

Complete code of controller