Windows 2012 Hosting - MVC 6 and SQL 2014 BLOG

Tutorial and Articles about Windows Hosting, SQL Hosting, MVC Hosting, and Silverlight Hosting

ASP.NET MVC 5.1 Hosting :: ASPHostPortal.com Proudly Launches ASP.NET MVC 5.1 Hosting

clock January 28, 2014 07:57 by author Ben

ASPHostPortal.com officially launches ASP.NET MVC 5.1  hosting at affordable prices. Instant Setup, Fast and Friendly Support!

ASPHostPortal.com, a leading innovator in Windows Hosting, announces the launch of ASP.NET MVC 5.1 Hosting. The ASP.NET MVC 5.1 Framework is the latest evolution of Microsoft’s ASP.NET web platform. It provides a high-productivity programming model that promotes cleaner code architecture, test-driven development, and powerful extensibility, combined with all the benefits of ASP.NET.

ASP.NET MVC 5.1 contains a number of advances over previous versions, including the ability to define routes using C# attributes and the ability to override filters,Enum support in Views, Support for current Context in Unobtrusive Ajax, Filter Overrides and etc. The user experience of building MVC applications has also been substantially improved.

“Our customers have been asking us about MVC 5.1 and we are happy to deliver a hosting platform that supports all the latest in the Microsoft Web Stack.” said said Dean Thomas, Manager at ASPHostPortal.com.  "And it proves that we remain at the forefront in Microsoft technology".

Where to look for the best ASP.NET MVC 5.1 hosting service? How to know more about the different types of hosting services? Read more about it on http://www.asphostportal.com.


About ASPHostPortal.com:

ASPHostPortal.com is a hosting company that best support in Windows and ASP.NET-based hosting. Services include shared hosting, reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server, and architecting highly scalable solutions. As a leading small to mid-sized business web hosting provider, ASPHostPortal.com strive to offer the most technologically advanced hosting solutions available to all customers across the world. Security, reliability, and performance are at the core of hosting operations to ensure each site and/or application hosted is highly secured and performs at optimum level.



Free SQL Server Hosting :: How to Handle Error : 1326 Cannot connect to Database Server Error: 40 – Could not open a connection to SQL Server

clock January 21, 2014 05:19 by author Ben

If you are receiving following error:

TITLE: Connect to Server
Cannot connect to Database Server.
ADDITIONAL INFORMATION:
An error has occurred while establishing a connection to the server.  When connecting to SQL Server 2008, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: Named Pipes Provider, error: 40 – Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 1326)


Now if
SQL Server can be connected perfectly from local system but can not be connected from remote system, in that case firewall of the server where SQL Server is installed can be issue.

Follow instructions of this article to fix the issue.

Go to control panel >> Firewall Settings >> Add SQL Server’s Port to Exception List.



Click Add Port and fill this :


Now try to connect to SQL Server again. It will allow you to connect to server successfully.

About the Company
ASPHostPortal.com is a hosting company that best support in Windows and ASP.NET-based hosting. Services  include shared hosting, reseller hosting, and sharepoint hosting, with specialty in ASP.NET, SQL Server,  and architecting highly scalable solutions. As a leading small to mid-sized business web hosting  provider, ASPHostPortal.com strive to offer the most technologically advanced hosting solutions available to  all customers across the world.
Come to the website to know more details.

 



.NET 4.5.1 Hosting - ASPHostPortal.com :: Confirmation Before Deleting Data in ASP.NET Application

clock January 13, 2014 05:31 by author Ben

It is always great idea to ask before delete e.g. sometimes by mistake you can press the delete button that can delete important records from your website so its always suggested that there should be confirmation to delete before deletion of any record.

Allowing a user to delete a row from a database table using a Datagrid is handy, but dangerous if you just delete immediately upon pressing a button. A better way is to pop up a dialog asking the user to confirm his or her desire to delete the record. To do this requires a little javascript, as well as a change in the usual way of placing a delete button (linkbutton or pushbutton) in the datagrid. Following the Visual Studio .NET way, a ButtonColumn gets added to the datagrid. The ButtonColumn, however, has no ID property and we need one in order to associate the javascript function with the button. We can get around this by adding a template column with a button rather than adding a ButtonColumn.

We add the template column as shown below in the file, ConfirmDelDG.aspx. There are several things to take note of in the .aspx file. We'll take them in order of appearance. First, between the <head>...</head> tags is our javascript function named confirm_delete. This simply pops up a confirmation dialog asking the user if he is sure he wants to delete the record. If OK is clicked, the delete happens. If Cancel is clicked, nothing happens.

<%@ Page Language="vb" Src="ConfirmDelDG.aspx.vb" Inherits="ConfirmDelDG" AutoEventWireup="false" %>
 <html>
 <head>
 <title>ConfirmDelDG</title>
 <meta name="GENERATOR" content="Microsoft Visual Studio .NET 4.5.1">
 <meta name="CODE_LANGUAGE" content="Visual Basic .NET 4.5.1">
 <meta name=vs_defaultClientScript content="JavaScript">
 <meta name=vs_targetSchema content="">
 <script language="javascript">
 function confirm_delete()
 {
   if (confirm("Are you sure you want to delete this item?")==true)
     return true;
   else
     return false;
 }
 </script>
 </head>
 <body>
 <form method="post" runat="server" ID="Form1"><br><br>
 <asp:DataGrid id="dtgProducts" runat="server"
               CellPadding="6" AutoGenerateColumns="False"
               OnDeleteCommand="Delete_Row" BorderColor="#999999"
               BorderStyle="None" BorderWidth="1px"
               BackColor="White" GridLines="Vertical">
   <AlternatingItemStyle BackColor="#DCDCDC" />
   <ItemStyle ForeColor="Black" BackColor="#EEEEEE" />
   <HeaderStyle Font-Bold="True" ForeColor="White" BackColor="#000084" />
   <Columns>
     <asp:BoundColumn Visible="False" DataField="ProductID" ReadOnly="True" />
     <asp:BoundColumn DataField="ProductName" ReadOnly="True" HeaderText="Name" />
     <asp:BoundColumn DataField="UnitPrice" HeaderText="Price" DataFormatString="{0:c}"
                      ItemStyle-HorizontalAlign="Right" />
     <asp:TemplateColumn>
     <ItemTemplate>
     <asp:Button id="btnDelete" runat="server" Text="Delete" CommandName="Delete" />
     </ItemTemplate>
     </asp:TemplateColumn>
   </Columns>
 </asp:DataGrid>
 </form>
 </body>
 </html>


And now for the codebehind file ConfirmDelDG.aspx.vb. We will take a look at it in several sections for ease of discussion and hopefully easier reading. This first section just contains the usual declarations, the Page_Load subroutine and a BindTheGrid subroutine which creates a DataSet and binds the grid. Nothing out of the ordinary here.

 Imports System.Data
 Imports System.Data.SqlClient
 Imports System.Configuration
 Imports System.Web.UI.WebControls
 
 Public Class ConfirmDelDG
   Inherits System.Web.UI.Page
 
   Protected WithEvents dtgProducts As System.Web.UI.WebControls.DataGrid
   Private strConnection As String = ConfigurationSettings.AppSettings("NorthwindConnection")
   Private strSql As String = "SELECT ProductID, ProductName, UnitPrice " _
                            & "FROM Products WHERE CategoryID = 1"
   Private objConn As SqlConnection
 
   Private Sub Page_Load(ByVal Sender As System.Object, ByVal E As System.EventArgs) Handles MyBase.Load
     If Not IsPostBack Then
       BindTheGrid()
     End If
   End Sub
 
   Private Sub BindTheGrid()
     Connect()
     Dim adapter As New SqlDataAdapter(strSql, objConn)
     Dim ds As New DataSet()
     adapter.Fill(ds, "Products")
     Disconnect()
 
     dtgProducts.DataSource = ds.Tables("Products")
     dtgProducts.DataBind()
   End Sub

The next subroutine, dtgProducts_ItemDataBound, is the secret to making our confirmation dialog work. We must add an OnClick event handler to each delete button on the datagrid. We can make use of ItemDataBound to do this. We dimension a variable ("btn") as type Button. We then check that ItemType is type Item or type AlternatingItem. We then use the FindControl method to find a control of type Button with an ID of "btnDelete" (the ID we gave the delete button on the aspx page). Having an ID such as "btnDelete" is why we had to use a TemplateColumn rather than a ButtonColumn which has no ID property. Once we find the button, we use Attributes.Add to call our javascript routine confirm_delete().

Private Sub dtgProducts_ItemDataBound (ByVal sender As System.Object, _
     ByVal e As DataGridItemEventArgs) Handles dtgProducts.ItemDataBound
     Dim btn As Button
     If e.Item.ItemType = ListItemType.Item or e.Item.ItemType = ListItemType.AlternatingItem Then
       btn = CType(e.Item.Cells(0).FindControl("btnDelete"), Button)
       btn.Attributes.Add("onclick", "return confirm_delete();")
     End If
   End Sub


This last section, Delete_Row(), is where the row is actually deleted. The method presented here is out of the ordinary for me in that I usually use SQL to delete the record. The technique presented here, however, first marks the row as deleted in the Dataset, and then, in a commented out section, uses the update method to actually delete the row from the database table. Because this is being run from my hosting provider's Northwind database I cannot actually delete rows from the Products table. If you run the example program you may notice seemingly odd behaviour. If you delete a row, it will seem to be deleted (it will disappear from the grid). But if you then delete another row, it will disappear, but the first row you deleted will reappear. This is normal behavior since I am not really deleting the rows from the database, only from the dataset. If you uncomment out the lines where noted, the deletes will actually occur in the database also.

Public Sub Delete_Row(ByVal Sender As Object, ByVal E As DataGridCommandEventArgs)
     ' Retrieve the ID of the product to be deleted
     Dim ProductID As system.Int32 = System.Convert.ToInt32(E.Item.Cells(0).Text)
     dtgProducts.EditItemIndex = -1
     ' Create and load a DataSet
     Connect()
     Dim adapter As New SqlDataAdapter(strSql, objConn)
     Dim ds As New DataSet()
     adapter.Fill(ds, "Products")
     Disconnect()
     ' Mark the product as Deleted in the DataSet
     Dim tbl As DataTable = ds.Tables("Products")
     tbl.PrimaryKey = New DataColumn() _
                     { _
                       tbl.Columns("ProductID") _
                     }
     Dim row As DataRow = tbl.Rows.Find(ProductID)
     row.Delete()
     ' Reconnect the DataSet and delete the row from the database
     '-----------------------------------------------------------
     ' Following section commented out for demonstration purposes
     'Dim cb As New SqlCommandBuilder(adapter)
     'Connect()
     'adapter.Update(ds, "Products")
     'Disconnect()
     '-----------------------------------------------------------
     ' Display remaining rows in the DataGrid
     dtgProducts.DataSource = ds.Tables("Products")
     dtgProducts.DataBind()
   End Sub
 End Class

That's about Confirmation Before Deleting Data in ASP.NET Application. For more information please visit ASPHostPortal.com.



 



About ASPHostPortal.com

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

 photo ahp banner aspnet-01_zps87l92lcl.png

Author Link

Corporate Address (Location)

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

Sign in