ASP.NET 4.5 and ASP.NET Core 1 Hosting BLOG

Tutorial and Articles about ASP.NET 4.0 and the latest ASP.NET 4.5 Hosting

ASP.NET Hosting - ASPHostPortal.com :: How to Solve Unexpected Error in ASP.NET

clock November 25, 2016 10:06 by author Dan

According to dotnettricks website, Some times after hosting web application on the server, we get unexpected error as shown in the below fig. But we did get the detailed message for the unexpected errror. In this article, I would like to share how can we get detailed message for the unexpected error.

This type of unexpected error may occurs on local or remote server. In asp.net, we can find the exact error message by setting mode="Off" with in customErrors tag in web.config of our application. This is the way by which we can find out the exact error in our web application.

     <system.web>
    <customErrors mode="Off">
     </customErrors>
     ...
     ...
     </system.web>


When we set the customErrors mode="Off" then we can easily track the error in the application as shown in the fig.

In Asp.net, there are three error modes to trace an error. These modes decide whether or not an error message is displayed. RemoteOnly mode is default mode for displaying error messages.

Off Mode

This mode is responsible for displaying error mesage on local and remote server in case of an error.

On Mode

This mode is responsible for displaying custom error page with message on local and remote server in case of an error. By using this mode, we can show our own custom error messages page for specific errors on local and remote server.

RemoteOnly

This mode is responsible for displaying error mesage on remote server only in case of an error. By using this mode, we can show our own custom error messages page for specific errors on remote server only.

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice.



ASPHostPortal.com Announces Umbraco 7.5.4 Hosting Solution

clock November 22, 2016 10:48 by author Dan

ASPHostPortal.com provides affordable and high performance Umbraco 7.5.4 hosting to customers around the world. We strongly believe in high quality standards and Hence you’ll always find our services better than every other host in this industry. We only use the best hardware, super fast network, covered by 24/7 Support Team. Our Umbraco 7.5.4 Hosting plans come with up to 99.99% uptime and 30-Day Full Money Back Guarantee.

Umbraco is strongly supported by both an active and welcoming community of users around the world, and backed up by a rock-solid commercial organization providing professional support and tools. Umbraco can be used in its free, open-source format with the additional option of professional tools and support if required.

With simple and customisable editing and content creation tools, it's easy to manage and maintain your website exactly how you want it. Umbraco doesn't dictate how you should work - that should be up to you, not your content management system.

ASPHostPortal.com offers Umbraco 7.5.4 Hosting with expert team support. We offer Umbraco 7.5.4 hosting with affordable price, a lot of features, 99.99% uptime guarantee, 24/7 support, and 30 days money back guarantee. We strive to make sure that all customers have the finest web-hosting experience as possible. To learn more about our Umbraco 7.5.4 Hosting, please visit http://asphostportal.com/Umbraco-7-5-4-Hosting

About ASPHostPortal.com:
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET & Linux Hosting. ASPHostPortal.com has ability to support the latest Microsoft, ASP.NET, and Linux technology, such as: such as: WebMatrix, Web Deploy, Visual Studio, Latest ASP.NET Version, Latest ASP.NET MVC Version, Silverlight and Visual Studio Light Switch, Latest MySql version, Latest PHPMyAdmin, Support PHP, etc. Their service includes shared hosting, reseller hosting, and Sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are at the core of hosting operations to make certain every website and software hosted is so secured and performs at the best possible level.



ASP.NET Hosting - ASPHostPortal.com :: Change Startup.cs and wwwroot folder name in ASP.NET Core

clock November 22, 2016 06:45 by author Armend

ASP.NET Core runs on conventions. It expects Startup.cs file for starting up the ASP.NET Core application and wwwroot folder for the application’s static contents. But what if you want to change the name of Startup.cs and wwwroot to your choice? Well, that can be done. In this short post, we will see how to change Startup.cs and wwwroot folder name in ASP.NET Core.

 

Change Startup.cs class name

You can easily change the startup class name. Open the Startup.cs file and change the startup class name from Startup to “MyAppStartup” (or anything of your choice). And also change the name of the constructor.

public class MyAppStartup
{
    public MyAppStartup(IHostingEnvironment env)
    {
       
    }
}

Now you need to tell ASP.NET Core about new Startup class name, otherwise application will not start. So open Program.cs file and change the UseStartup() call as follows:

public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup<MyAppStartup>()
        .Build();
    host.Run();
}

That’s it.

Change wwwroot folder name

Earlier, I posted how to rename the wwwroot folder via hosting.json file but that doesn’t seem to work now. To change the name, right on wwwroot folder and rename it to “AppWebRoot” (or anything of your choice).
Now, open Program.cs file and add highlighted line of code to Main().

public static void Main(string[] args)
{
    var host = new WebHostBuilder()
        .UseKestrel()
        .UseWebRoot("AppWebRoot")
        .UseContentRoot(Directory.GetCurrentDirectory())
        .UseIISIntegration()
        .UseStartup<MyStartup>()
        .Build();
 
    host.Run();
}

That’s it.
Hope you liked it. Thank you for reading.

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice



ASP.NET Hosting - ASPHostPortal.com :: All About ASP.NET DBNull Value

clock November 18, 2016 10:14 by author Dan

According to asp.net-informations website, The DBNull represents an uninitialized variant or nonexistent database column. It is not the number zero or it is not an empty string value. DBNull is a singleton class, which means only this instance of this class can exist. The DBNull.Value member represents the sole DBNull object.

In many situations while reading data from DataSource, we have seen the error message like the following :

  Conversion from type 'DBNull' to type '' is not valid

This message is getting because the ASP.NET program unable to handle DBNull value. In these cases you can determine whether a value retrieved from a database field is a DBNull value by passing the value of that field to the DBNull.Value.Equals method.

vb.net

  If IsDBNull(ds.Tables(0).Rows(i).Item(0)) Then
    Label1.Text = "DBNULL exist in the field "

  End If


C#

  if (ds.Tables[0].Rows[0].ItemArray[0] == System.DBNull.Value)
  {
    Label1.Text = "DBNULL exist in the field ";

  }


The following ASP.NET program is checking wether the retrieved values is DBNull.

Default.aspx

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
    <br />
    <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
    </div>
    </form>
</body>
</html>

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice



ASPHostPortal.com Announces ASP.NET Core 1.1 Hosting Solution

clock November 15, 2016 07:27 by author Dan

Established in 2008, ASPHostPortal.com is one of the leading ASP.NET hosting provider offering quality services with premium support. We maintain and operates its own network. Our superior servers are housed in 12 different countries with up to 1000 Mbps connection and Cisco Hardware Firewalls. Our company is passionate about hosting and strive to deliver an excellent level of service to each customer. Today, we offer high quality ASP.NET Core 1.1 hosting at low price.

Microsoft is happy to announce the release of ASP.NET Core 1.1 Preview 1. This release includes a bunch of great new features along with many bug fixes and general enhancements. They invite all people to try out the new features and to provide feedback.

URL Rewriting middleware is one of new features are available in ASP.NET Core 1.1. This allows mapping a public URL space, designed for consumption of your clients, to whatever representation the downstream components of your middleware pipeline require as well as redirecting clients to different URLs based on a pattern.

ASPHostPortal.com offers ASP.NET Core 1.1 Hosting with expert team support. We offer ASP.NET Core 1.1 hosting with affordable price, a lot of features, 99.99% uptime guarantee, 24/7 support, and 30 days money back guarantee. We strive to make sure that all customers have the finest web-hosting experience as possible. To learn more about our ASP.NET Core 1.1 Hosting, please visit http://asphostportal.com/ASPNET-Core-1-1-Hosting

About ASPHostPortal.com:
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET & Linux Hosting. ASPHostPortal.com has ability to support the latest Microsoft, ASP.NET, and Linux technology, such as: such as: WebMatrix, Web Deploy, Visual Studio, Latest ASP.NET Version, Latest ASP.NET MVC Version, Silverlight and Visual Studio Light Switch, Latest MySql version, Latest PHPMyAdmin, Support PHP, etc. Their service includes shared hosting, reseller hosting, and Sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are at the core of hosting operations to make certain every website and software hosted is so secured and performs at the best possible level.



ASP.NET Hosting - ASPHostPortal.com :: How To Create a Connection String and Working with SQL Server LocalDB

clock November 15, 2016 07:16 by author Armend

Creating a Connection String and Working with SQL Server LocalDB

The MovieDBContext class you created handles the task of  connecting to the database and mapping Movie objects to database  records. One question you might ask, though, is how to specify which database it will connect to. You don't actually have to specify which database to use,  Entity Framework will default to using  LocalDB. In this section we'll explicitly add  a connection string in the Web.config file of the application.

SQL Server Express LocalDB

LocalDB is a lightweight version of the SQL Server Express Database Engine that starts on demand and runs in user mode. LocalDB runs in a special execution mode of SQL Server Express that enables you to  work with databases as .mdf files. Typically, LocalDB database files  are kept in the App_Data folder of a web project.
SQL Server Express is not recommended for use in production web applications. LocalDB in particular should not be used for production with a web application because it is not designed to work with IIS. However, a LocalDB  database can be easily migrated to SQL Server or SQL Azure.
In Visual Studio 2013 (and in 2012), LocalDB is installed by default with Visual Studio.
By default, the Entity Framework looks for a connection string named the same as the object context class (MovieDBContext for this project).  For more  information see  SQL Server Connection Strings for ASP.NET Web Applications.
Open the application root Web.config file shown below. (Not the Web.config file in the Views folder.)

 

Find  the <connectionStrings>  element:

 

Add the following connection string to the <connectionStrings>  element in the Web.config file.

<add name="MovieDBContext"
   connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True"
   providerName="System.Data.SqlClient"
/>

The following example shows a portion of the Web.config file with  the new connection string added:

<connectionStrings>
    <add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\aspnet-MvcMovie-20130603030321.mdf;Initial Catalog=aspnet-MvcMovie-20130603030321;Integrated Security=True" providerName="System.Data.SqlClient" />
    <add name="MovieDBContext"    connectionString="Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\Movies.mdf;Integrated Security=True" providerName="System.Data.SqlClient"
/>

The two connection strings are very similar. The first connection string is  named DefaultConnection and is used for the membership database to control who can access the application. The connection string you've added specifies a LocalDB database named Movie.mdf located in the App_Data  folder.  We won't use the membership database in this tutorial, for more information on membership, authentication and security, see my tutorial Create an ASP.NET MVC app with auth and SQL DB and deploy to Azure App Service.
The name of the connection string must match the name of the DbContext class.

using System;
using System.Data.Entity;
namespace MvcMovie.Models
{
    public class Movie
    {
        public int ID { get; set; }
        public string Title { get; set; }
        public DateTime ReleaseDate { get; set; }
        public string Genre { get; set; }
        public decimal Price { get; set; }
    }

    public class MovieDBContext : DbContext
    {
        public DbSet<Movie> Movies { get; set; }
    }
}

You don't actually need to add the MovieDBContext connection string. If you don't specify a connection string, Entity Framework will create a LocalDB database in the users directory with the fully qualified name of the DbContext class (in this case MvcMovie.Models.MovieDBContext). You can name the database anything you like, as long as it has the .MDF  suffix. For example, we could name the database MyFilms.mdf.
Next, you'll build a new MoviesController class that you can use  to display the movie data and allow users to create new movie listings.

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best c



ASP.NET Hosting - ASPHostPortal.com :: All About ASP.NET Master Pages

clock November 11, 2016 10:31 by author Dan

According to venkataspinterview blog, What are Master Pages in ASP.NET? or What is a Master Page? ASP.NET master pages allow you to create a consistent layout for the pages in your application. A single master page defines the look and feel and standard behavior that you want for all of the pages (or a group of pages) in your application. You can then create individual content pages that contain the content you want to display. When users request the content pages, they merge with the master page to produce output that combines the layout of the master page with the content from the content page.

What are the 2 important parts of a master page?
The following are the 2 important parts of a master page
1. The Master Page itself
2. One or more Content Pages

Can Master Pages be nested?
Yes, Master Pages be nested.

What is the file extension for a Master Page?
.master

How do you identify a Master Page?
The master page is identified by a special @ Master directive that replaces the @ Page directive that is used for ordinary .aspx pages.

Can a Master Page have more than one ContentPlaceHolder?
Yes, a Master Page can have more than one ContentPlaceHolder

What is a ContentPlaceHolder?
ContentPlaceHolder is a region where replaceable content will appear.

How do you bind a Content Page to a Master Page?
MasterPageFile attribute of a content page's @ Page directive is used to bind a Content Page to a Master Page.

Can the content page contain any other markup outside of the Content control?
No.

What are the advantages of using Master Pages?
1. They allow you to centralize the common functionality of your pages so that you can make updates in just one place.
2. They make it easy to create one set of controls and code and apply the results to a set of pages. For example, you can use controls on the master page to create a menu that applies to all pages.
3. They give you fine-grained control over the layout of the final page by allowing you to control how the placeholder controls are rendered.
4. They provide an object model that allows you to customize the master page from individual content pages.

What are the 3 levels at which content pages can be attached to Master Page?
At the page level - You can use a page directive in each content page to bind it to a master page

At the application level - By making a setting in the pages element of the application's configuration file (Web.config), you can specify that all ASP.NET pages (.aspx files) in the application automatically bind to a master page.

At the folder level - This strategy is like binding at the application level, except that you make the setting in a Web.config file in one folder only. The master-page bindings then apply to the ASP.NET pages in that folder.

What is @MasterType directive used for?
@MasterType directive is used to create a strongly typed reference to the master page.

Are controls on the master page accessible to content page code?
Yes, controls on the master page are accessible to content page code.

At what stage of page processing master page and content page are merged?
During the initialization stage of page processing, master page and content page are merged.

Can you dynaimically assign a Master Page?
Yes, you can assign a master page dynamically during the PreInit stage using the Page class MasterPageFile property as shown in the code sample below.
void Page_PreInit(Object sender, EventArgs e)
{
this.MasterPageFile = "~/MasterPage.master";
}


Can you access non public properties and non public methods of a master page inside a content page?
No, the properties and methods of a master page must be public in order to access them on the content page.

From the content page code how can you reference a control on the master page?
Use the FindControl() method as shown in the code sample below.
void Page_Load()
{
// Gets a reference to a TextBox control inside
// a ContentPlaceHolder
ContentPlaceHolder ContPlaceHldr = (ContentPlaceHolder)Master.FindControl ("ContentPlaceHolder1");
if(ContPlaceHldr != null)
{
TextBox TxtBox = (TextBox)ContPlaceHldr.FindControl("TextBox1");
if(TxtBox != null)
{
TxtBox.Text = "TextBox Present!";
}
}
// Gets a reference to a Label control that not in
// a ContentPlaceHolder
Label Lbl = (Label)Master.FindControl("Label1");
if(Lbl != null)
{
Lbl.Text = "Lable Present";
}

}

Can you access controls on the Master Page without using FindControl() method?
Yes, by casting the Master to your MasterPage as shown in the below code sample.
protected void Page_Load(object sender, EventArgs e)
{
MyMasterPage MMP = this.Master;
MMP.MyTextBox.Text = "Text Box Found";
}

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice



ASPHostPortal.com Announces Windows Server 2016 Hosting Solution

clock November 8, 2016 08:05 by author Dan

ASPHostPortal.com serve people since 2008 and we know how to deliver Powerful, Fast and Reliable Windows Server 2016 Hosting with the Superior Customer Support. Our superior servers are housed in 12 different countries with up to 1000MB/s connection and Cisco Hardware Firewalls. Fully managed and monitored around the clock, our servers run on Windows Operating system with lots of memory (RAM) and up multiple Quad-Core Xeon CPU's, utilizing power of the Cloud Services. Our Windows Server 2016 Hosting plans come with up to 99.99% uptime and 30-Day Full Money Back Guarantee.

Windows Server 2016 is a server operating system developed by Microsoft as part of the Windows NT family of operating systems, developed concurrently with Windows 10. The first early preview version (Technical Preview) became available on October 1, 2014 together with the first technical preview of System Center.

Securely deploy and run your existing applications on Windows Server 2016 to transform them into new cloud-native models. Help developers to innovate and create on-premises and cloud applications using the latest technology—containers, microservices, and Nano Server.

ASPHostPortal.com offers Windows Server 2016 Hosting with expert team support. We offer Windows Server 2016 hosting with affordable price, a lot of features, 99.99% uptime guarantee, 24/7 support, and 30 days money back guarantee. We strive to make sure that all customers have the finest web-hosting experience as possible. To learn more about our Windows Server 2016 Hosting, please visit http://asphostportal.com/Windows-Server-2016-Hosting.aspx

About ASPHostPortal.com:
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET & Linux Hosting. ASPHostPortal.com has ability to support the latest Microsoft, ASP.NET, and Linux technology, such as: such as: WebMatrix, Web Deploy, Visual Studio, Latest ASP.NET Version, Latest ASP.NET MVC Version, Silverlight and Visual Studio Light Switch, Latest MySql version, Latest PHPMyAdmin, Support PHP, etc. Their service includes shared hosting, reseller hosting, and Sharepoint hosting, with speciality in ASP.NET, SQL Server, and Linux solutions. Protection, trustworthiness, and performance are at the core of hosting operations to make certain every website and software hosted is so secured and performs at the best possible level.



ASP.NET Hosting - ASPHostPortal.com :: Handle Multiple Submit Buttons On The Same Form in MVC 6

clock November 8, 2016 07:11 by author Armend

In this post we will explain you about Handling multiple submit buttons on the same form in MVC.To fix this problem, I’m progressing to justify the varied techniques for handling multiple buttons on the same form in Sometimes you got situation like more than one submit buttons on a similar form in ASP.NET MVC 6. At that point, How we will handle the click event of every and each buttons on your form? Suppose you’ve got a user Login form.

On the above picture, we have the SignUp, SignIn and the Cancel buttons. Suppose on Signup button click you have to open Signup window & on SignIn button click you have to open Login window and on Cancel button click you are returning to home page. For handling all of the above buttons, we have the following methods:

  • Export Gridview to Excel: Gridview to Excel
  • Insert,Update,Delete in ModalPopup CRUD operation in ModalPopup
  • Read and Write in Text File in ASP.NET Read and Write File in ASP.NET

Now, Make the view Form with Multiple Button in Home Folder with the following code.

MultipleCommand.cshtml
@model Mvc4_Multiple_Submit_Button.Models.RegistrationModel
@{
ViewBag.Title = "Handling Multiple Command Buttons";
}
<script src="../../Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.min.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.min.js" type="text/javascript"></script>
<h2>User's Signup Form</h2>
@using (Html.BeginForm("MultipleCommand", "Home", FormMethod.Post, new { id = "submitForm" }))
{
<fieldset>
<legend>Registration Form</legend>
<ol>
<li>
@Html.LabelFor(m => m.Name)
@Html.TextBoxFor(m => m.Name, new { maxlength = 50 })
@Html.ValidationMessageFor(m => m.Name)
</li>
<li>
@Html.LabelFor(m => m.Address)
@Html.TextAreaFor(m => m.Address, new { maxlength = 200 })
@Html.ValidationMessageFor(m => m.Address)
</li>
<li>
@Html.LabelFor(m => m.MobileNo)
@Html.TextBoxFor(m => m.MobileNo, new { maxlength = 10 })
@Html.ValidationMessageFor(m => m.MobileNo)
</li>
</ol>
<button type="submit" id="btnSave" name="Command" value="Save">
Save</button>
<button type="submit" id="btnSubmit" name="Command" value="Submit">
Submit</button>
<button type="submit" id="btnCancel" name="Command" value="Cancel" onclick="$('#submitForm').submit()">
Cancel (Server Side)</button>
<button type="submit" id="btnCancelSecForm" name="Command" value="Cancel" onclick="$('#cancelForm').submit()">
Cancel (Server Side by Second Form)</button>
<button name="ClientCancel" type="button" onclick=" document.location.href = $('#cancelUrl').attr('href');">
Cancel (Client Side)</button>
<a id="cancelUrl" href="@Html.AttributeEncode(Url.Action("Index", "Home"))" style="display:none;">
</a>
</fieldset>
}
@using (Html.BeginForm("MultipleButtonCancel", "Home", FormMethod.Post, new { id = "cancelForm" })) { }

Next step, in Homecontroller include the MultipleCommand Method to handle the multiple button with the following code.

HomeController.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Mvc4_Multiple_Submit_Button.Models;
namespace Mvc4_Multiple_Submit_Button.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
return View();
}
public ActionResult MultipleCommand()
{
return View();
}
[HttpPost]
public ActionResult MultipleCommand(RegistrationModel mReg, string Command)
{
if (Command == "Save")
{
//TO DO : for Save button Click
}
else if (Command == "Submit")
{
//TO DO : for Submit button Click
}
else
{
//TO DO : for Cancel button Click
return RedirectToAction("Index");
}
return View();
}
[HttpPost]
public ActionResult MultipleButtonCancel()
{
//TO DO : for Cancel button Click
return RedirectToAction("Index");
}
}
}


Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice



ASP.NET Hosting - ASPHostPortal.com :: Easy steps to delete duplicate rows from table in sql server

clock November 4, 2016 11:25 by author Dan

Based on ASP.NET Corner blog. I have two columns Name and Age in my Table(MyTable). From the MyTable I want to delete only duplicate records. So the below Query will help you to delete or remove the duplicate rows from the MyTable.

Below is MyTable output:

SELECT * FROM MyTable

Current output:

Name    Age
vijay    30
antony    40
Aruna    28
antony    40
chander35
mark    42
vijay    30

Remove duplicate rows from the table:
The below query will help you to delete duplicate row from your table. Here we used Row_Number() function and PARTITION BY key words to remove the duplicate rows.

DELETE SUB FROM
(SELECT ROW_NUMBER() OVER (PARTITION BY Name, Age ORDER BY Name) cnt
 FROM MyTable) SUB
WHERE SUB.Cnt > 1


After the query execution the output is:

Name    Age
Aruna    28
antony    40
chander    35
mark    42
vijay    30

How to use Row_Number in SQL Select query:

SELECT ROW_NUMBER() OVER(ORDER BY Age) FROM mytable

Best ASP.NET Hosting Recommendation

ASPHostPortal.com provides its customers with Plesk Panel, one of the most popular and stable control panels for Windows hosting, as free. You could also see the latest .NET framework, a crazy amount of functionality as well as Large disk space, bandwidth, MSSQL databases and more. All those give people the convenience to build up a powerful site in Windows server. ASPHostPortal.com offers ASP.NET hosting starts from $1/month only. They also guarantees 30 days money back and guarantee 99.9% uptime. If you need a reliable affordable ASP.NET Hosting, ASPHostPortal.com should be your best choice



Cheap ASP.NET 4.5 Hosting

We’re a company that works differently to most. Value is what we output and help our customers achieve, not how much money we put in the bank. It’s not because we are altruistic. It’s based on an even simpler principle. "Do good things, and good things will come to you".

Success for us is something that is continually experienced, not something that is reached. For us it is all about the experience – more than the journey. Life is a continual experience. We see the Internet as being an incredible amplifier to the experience of life for all of us. It can help humanity come together to explode in knowledge exploration and discussion. It is continual enlightenment of new ideas, experiences, and passions


Author Link


 

Corporate Address (Location)

ASPHostPortal
170 W 56th Street, Suite 121
New York, NY 10019
United States

Tag cloud

Sign in