All About ASP.NET and ASP.NET Core 2 Hosting BLOG

Tutorial and Articles about ASP.NET and the latest ASP.NET Core

ASP.NET Hosting - ASPHostPortal :: How To Show Data In Doughnut Chart Using ASP.NET

clock January 15, 2015 06:49 by author Mark

Doughnut Chart In ASP.Net

Today i will explains about how to show data in doughnut chart. In this article we will learn about the Doughnut Chart of ASP.Net.
what's Donut or Doughnut chart?? Donut or Doughnut chart is just a simple pie chart with a hole inside. You can define hole radius to any size you need, both in percent or pixels. Sometimes we need to show data in a chart like a Doughnut chart, such as to show quarterly data and on, so by considering the preceding requirement and to introduce the ASP.Net Doughnut Chart controls I have decided to write this article.

Let us learn about the ASP.Net chart type Doughnut chart that provides a powerful UI and great design quality. We will learn about these chart type controls step-by-step. All the charts are in the System.Web.UI.DataVisualization.Charting namespace.
The chart data is represented using the following points:

  • X Axis: the horizontal line of the chart termed the X axis
  • Y Axis: the vertical line of the chart termed the Y axis

Now let us learn about the properties of the Doughnut chart. A Doughnut chart type has the following common properties:

  • AlternetText: Sets the alternate text when the image is not available.
  • Annotation: Stores the chart annotations.
  • AntiAliasing: sets a value that determines whether anti-aliasing is used when text and graphics are drawn.
  • BackGradientStyle: sets the orientation for the background gradient for the Chart control. Also determines whether a gradient is used, the default is None.
  • Backcolor: sets the background color for a chart, the default color is White.
  • BackImage: sets the background image for the chart control.
  • BackHatchStyle: sets the hatching style for the chart control, the default is None.
  • Height: Sets the height for the chart control.
  • Width: Sets the width for the chart control.
  • Palette: Sets the style with the color for the chart control, the default style is Chocolate.
  • PaletteCustomColors: Sets the custom color for the chart control.
  • Series: Sets the series collection for the chart control.
  • Legends: Sets the series of legends to the chart.

Now let us show the preceding explanation with a practical example by creating a simple web application.

Step 1: Create the table for the chart data

  • Now before creating the application, let us create a table named QuarterwiseSale in a database from where we show the records in the chart using the following script:

CREATE TABLE [dbo].[QuarterwiseSale](    
    [id] [int] IDENTITY(1,1) NOT NULL,    
    [Quarter] [varchar](50) NULL,    
    [SalesValue] [money] NULL,    
 CONSTRAINT [PK_QuarterwiseSale] PRIMARY KEY CLUSTERED     
    (    
    [id] ASC    
    )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF,IGNORE_DUP_KEY = OFF,ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]    
    ) ON [PRIMARY]   

  • The table has the following fields (shown in the following image): 
  • Now insert some records using the following script: 

SET IDENTITY_INSERT [dbo].[QuarterwiseSale] ON          
    GO    
    INSERT [dbo].[QuarterwiseSale] ([id], [Quarter], [SalesValue]) VALUES     (1, N'Q1', 100.0000)    
    GO    
    INSERT [dbo].[QuarterwiseSale] ([id], [Quarter], [SalesValue]) VALUES     (2, N'Q2', 50.0000)    
    GO    
    INSERT [dbo].[QuarterwiseSale] ([id], [Quarter], [SalesValue]) VALUES     (3, N'Q3', 150.0000)    
    GO    
    INSERT [dbo].[QuarterwiseSale] ([id], [Quarter], [SalesValue]) VALUES     (4, N'Q4', 200.0000)    
    GO    
    SET IDENTITY_INSERT [dbo].[QuarterwiseSale] OFF    
    GO   

Now the records will look as in the following image:
Now create the Stored Procedure to fetch the records from the database as in the following:

Create Procedure [dbo].[GetSaleData]    
    (    
    @id int=null             
    )    
    as    
    begin    
    Select Quarter,SalesValue from QuarterwiseSale    
    End 
  

I hope you have the same type of table and records as above.

Step: 2 Create Web Application

  • Now create the project using the following:
  • "Start" - "All Programs" - "Microsoft Visual Studio 2013".
  • "File" - "New Project" - "C#" - "Empty Project" (to avoid adding a master page).
  • Provide the project a name such as UsingDoughnutChart or another as you wish and specify the location.
  • Then right-click on Solution Explorer and select "Add New Item" then select Default.aspx page.
  • Drag and Drop a Chart control from the ToolBox onto the Default.aspx page.
  • Now the Default.aspx source code will be as follows:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>         
    <%@ Register Assembly="System.Web.DataVisualization, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"  
        Namespace="System.Web.UI.DataVisualization.Charting" TagPrefix="asp" %>  
    <!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 runat="server">  
        <title>Article by Vithal Wadje</title>  
    </head>  
    <body bgcolor="silver">  
        <form id="form1" runat="server">  
        <h4 style="color: Navy;">  
            Article for C#Corner  
        </h4>  
        <asp:Chart ID="Chart1" runat="server" BackColor="0, 0, 64" BackGradientStyle="LeftRight"  
            BorderlineWidth="0" Height="360px" Palette="None" PaletteCustomColors="Maroon"  
            Width="380px" BorderlineColor="64, 0, 64">  
            <Titles>  
                <asp:Title ShadowOffset="10" Name="Items" />  
            </Titles>  
            <Legends>  
                <asp:Legend Alignment="Center" Docking="Bottom" IsTextAutoFit="False" Name="Default"  
                    LegendStyle="Row" />  
            </Legends>  
            <Series>  
                <asp:Series Name="Default" />  
            </Series>  
            <ChartAreas>  
                <asp:ChartArea Name="ChartArea1" BorderWidth="0" />  
            </ChartAreas>  
        </asp:Chart>  
        </form>  
    </body>  
    </html> 

  • Create a method to bind the chart control. Then open the default.aspx.cs page and create the following function named Bindchart to bind the Chart Control as in the following:

private void Bindchart()  
        {  
            connection();  
            com = new SqlCommand("GetSaleData", con);  
            com.CommandType = CommandType.StoredProcedure;  
            SqlDataAdapter da = new SqlDataAdapter(com);  
            DataSet ds = new DataSet();  
            da.Fill(ds);         
            DataTable ChartData = ds.Tables[0];  
            //storing total rows count to loop on each Record  
            string[] XPointMember = new string[ChartData.Rows.Count];  
            int[] YPointMember = new int[ChartData.Rows.Count];         
            for (int count = 0; count < ChartData.Rows.Count; count++)  
            {  
                //storing Values for X axis  
                XPointMember[count] = ChartData.Rows[count]["Quarter"].ToString();  
                //storing values for Y Axis  
                YPointMember[count] = Convert.ToInt32(ChartData.Rows[count]["SalesValue"]);  
            }  
            //binding chart control  
            Chart1.Series[0].Points.DataBindXY(XPointMember, YPointMember);         
            //Setting width of line  
            Chart1.Series[0].BorderWidth = 10;  
            //setting Chart type   
            Chart1.Series[0].ChartType = SeriesChartType.Doughnut;       
            foreach (Series charts in Chart1.Series)  
            {  
                foreach (DataPoint point in charts.Points)  
                {  
                    switch (point.AxisLabel)  
                    {  
                        case "Q1": point.Color = Color.YellowGreen; break 
                        case "Q2": point.Color = Color.Yellow; break;  
                        case "Q3": point.Color = Color.SpringGreen; break;
                    }  
                    point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel);         
                }  
            }           
            //Enabled 3D  
          //  Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;
            con.Close();         
        } 

Note that we have written a small code snippet to provide the different color for each point as in the following:

//To give different color for each point             
    foreach (Series charts in Chart1.Series)      
           {      
               foreach (DataPoint point in charts.Points)      
               {      
                   switch (point.AxisLabel)      
                   {      
                       case "Q1": point.Color = Color.RoyalBlue; break;   
                       case "Q2": point.Color = Color.SaddleBrown; break; 
                       case "Q3": point.Color = Color.SpringGreen; break; 
                   }      
                   point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel);                
               }      
           }       

  • Now, call the preceding function on page load as in the following:

protected void Page_Load(object sender, EventArgs e)      
        {      
            if (!IsPostBack)      
            {      
                Bindchart();                 
            }      
        }  
  

  • The entire code of the default.aspx.cs page will look as follows:

      using System;  
    using System.Collections.Generic;  
    using System.Linq;  
    using System.Web;  
    using System.Web.UI;  
    using System.Web.UI.WebControls;  
    using System.Data.SqlClient;  
    using System.Configuration;  
    using System.Data;  
    using System.Web.UI.DataVisualization.Charting;  
    using System.Drawing;         
    public partial class _Default : System.Web.UI.Page  
    {  
        private SqlConnection con;  
        private SqlCommand com;  
        private string constr, query;  
        private void connection()  
        {  
            constr = ConfigurationManager.ConnectionStrings["getconn"].ToString();  
            con = new SqlConnection(constr);  
            con.Open();  
               }  
        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!IsPostBack)  
            {  
                Bindchart();    
            }  
        }     
        private void Bindchart()  
        {  
            connection();  
            com = new SqlCommand("GetSaleData", con);  
            com.CommandType = CommandType.StoredProcedure;  
            SqlDataAdapter da = new SqlDataAdapter(com);  
            DataSet ds = new DataSet();  
            da.Fill(ds);         
            DataTable ChartData = ds.Tables[0];         
            //storing total rows count to loop on each Record  
            string[] XPointMember = new string[ChartData.Rows.Count];  
            int[] YPointMember = new int[ChartData.Rows.Count];         
            for (int count = 0; count < ChartData.Rows.Count; count++)  
            {  
                //storing Values for X axis  
                XPointMember[count] = ChartData.Rows[count]["Quarter"].ToString();  
                //storing values for Y Axis  
                YPointMember[count] = Convert.ToInt32(ChartData.Rows[count]["SalesValue"]);         
            }  
            //binding chart control  
            Chart1.Series[0].Points.DataBindXY(XPointMember, YPointMember);         
            //Setting width of line  
            Chart1.Series[0].BorderWidth = 10;  
            //setting Chart type   
            Chart1.Series[0].ChartType = SeriesChartType.Doughnut;      
            foreach (Series charts in Chart1.Series)  
            {  
                foreach (DataPoint point in charts.Points)  
                {  
                    switch (point.AxisLabel)  
                    {  
                        case "Q1": point.Color = Color.YellowGreen; break 
                        case "Q2": point.Color = Color.Yellow; break;  
                        case "Q3": point.Color = Color.SpringGreen; break;
                    }  
                    point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel);  
                }  
            }    
            //Enabled 3D  
          //  Chart1.ChartAreas["ChartArea1"].Area3DStyle.Enable3D = true;  
            con.Close();  
        }  
    } 

We now have the entire logic to bind the chart from the database, let us run the application. The chart will look as follows:

I hope this article work for you.

TOP No#1 Recommended ASP.NET 5 Hosting

ASPHostPortal.com

ASPHostPortal.com  is the leading provider of Windows hosting and affordable ASP.NET Hosting. ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability.



ASP.NET MVC Hosting - ASPHostPortal.com :: Donut Caching with ASP.NET MVC 6

clock January 14, 2015 06:03 by author Ben

I'm working on a new personal project during my free time and I chose to develop it with ASP.NET MVC 6 (hosted on ASPHostPortal of course...) to test the new features of this version. In this project, I need to display "Logged in as xxxx " (if the user is logged...) in the header of the page. This is a simple scenario to implement but caching could complicate the development of my web app...



My header is in my layout and is used everywhere but I would like to place an OutputCacheAttribute on some actions (the home page, etc.). If I put the attribute on an action, all of my users will see an header with "logged in as xxxx" of the first incoming query!

The solution to this problem is named "Donut Caching": you send a cached page from the server with a "fresh" portion which is not in cache (the donut's hole).
Concretely, the server does not generate the requested page (query the DB, etc.): it just needs to take the cached version and replace a specific part.

Luckily, you do not need to develop your own custom OutputCacheAttribute because there is already a very good package (There's An App A Pack For That... thanks NuGet!): MvcDonutCaching for ASP.NET MVC 3 and later...

To install the package, you can search through NuGet or directly type the following command in the "Package Manager Console":

install-package MvcDonutCaching

The use of this package is very simple... They have created several extension methods for HtmlHelper with the usual parameters plus another boolean parameter: excludeFromParentCache. I just have to call my partial view (with the "connected has xxxx"...) like that:

@Html.Action("LoginHeader", "Account", new { lang }, true)\

The last parameter of Html.Action is set to true: this partial view will be excluded from the parent cache (if there is a cache on the action...). (do not pay attention to new { lang }, it's a route's value) To make it work, you must not use the OutputCacheAttribute but the DonutOutputCacheAttribute:

[DonutOutputCache(Duration = 60, VaryByParam = "lang")]
     public ActionResult Index(string lang)
     {
         ...
     
         return View();
     }

And that's it! The first request will be cached during 60 seconds but the LoginHeader partial view will be generated every time.

(note: of course, the donut caching only works on the server side...)

Best Hosting for Your ASP.NET MVC Hosting

Following reviewed for Best ASP.NET hosting companies that help with ASP.NET MVC, ASPHostPortal is Best ASP.NET Hosting Recommendation for ASP.NET MVC. They give 99,99% uptime assured, as well as 30 Days Money back assured, superb customer service, and many more.



ASPHostPortal.com Proudly Announces Umbraco 7.2.1 Hosting

clock January 13, 2015 08:53 by author Dan

ASPHostPortal.com, The Best, Cheap and Recommended ASP.NET Hosting offers Umbraco 7.2.1 Hosting with a combination of affordable price, excellent network, and 30 days money back guarantees. ASPHostPortal.com also provides full trust web hosting services for Umbraco 7.2.1 site.

Umbraco is a fully-featured open source content management system with the flexibility to run anything from small campaign or brochure sites right through to complex applications for Fortune 500's and some of the largest media sites in the world.

Umbraco is easy to learn and use, making it perfect for web designers, developers and content creators alike. 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.

ASPHostPortal.com, a windows-based hosting service provider offers the most reliable and stable Umbraco 7.2.1 web hosting infrastructure on the net with great features, fast and secure servers.  We has built the network like no other hosting company. Every facet of the network infrastructure scales to gigabit speeds with no single point of failure. All of windows hosting plan supports Umbraco 7.2.1 and customers can install it with just one click.

ASPHostPortal.com offer professional Umbraco 7.2.1 site start from $5/month. The following are the reasons why the customers choose and keep trust with our service:

High Performance and Reliable Server
We never ever overload the server with tons of clients. We always load balance the server to make sure we can deliver an excellent service, coupling with the high performance and reliable server.

Daily Backup Service
We realise that customer’s website is very important to their business and hence, we never ever forget to create a daily backup.

Best and Friendly Support
Our support team is extremely fast and can help you with setting up and using Umbraco 7.2.1 on your account. Our customer support will help you 24 hours a day, 7 days a week and 365 days a year.

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. With the Umbraco 7.2.1 in their hosting deal will make ASPHostPortal continue to be the Best ASP.NET hosting providers. To learn more about Umbraco 7.2.1 Hosting, please visit http://asphostportal.com/Umbraco-Hosting

About ASPHostPortal.com :
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. ASPHostPortal.com has ability to support the latest Microsoft and ASP.NET technology, such as: such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch. ASPHostPortal include shared hosting, reseller hosting, and sharepoint hosting, with speciality in ASP.NET, SQL Server, and architecting highly scalable solutions. ASPHostPortal.com strives to supply probably the most technologically advanced hosting solutions available to all consumers the world over. Protection, trustworthiness, and performance are on 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 :: How to Delete Record in GridView Using ASP.Net Ajax and jQuery

clock January 13, 2015 06:14 by author Mark

How to Delete Record in GridView Using ASP.Net Ajax and jQuery

This article will explains how to delete record in GridView using ASP.NET Ajax and jQuery

  • Now first create the Employee table in the database.

CREATE TABLE tbl_Emp(Empid int NULL,EmpName varchar(250) NULL, Gender varchar(20), EmpAddress varchar(500) NULL,City varchar(250) NULL,Salary int NULL, Fk_DepId int)

  • And insert some records into the table:

INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(1, 'A' , 'Male', 'Demo Address', 'Agra', 4000, 3)  
INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(2, 'B' , 'Male', 'Demo Address', 'Ghaziabad', 0, 2)  
INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(3, 'C' , 'Male', 'Demo Address', 'Agra', 1000, 2)  
INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(4, 'D' , 'Female', 'Demo Address', 'Mathura', 1000, 2)  
INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(5, 'E' , 'Female', 'Demo Address', 'Agra', 4000, 3)  
INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(6, 'F' , 'Male', 'Demo Address', 'Agra', 5000, 2)  
INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(7, 'G' , 'Male', 'Demo Address', 'Noida', 4000, 1)  
INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(8, 'H' , 'Male', 'Demo Address', 'Agra', 4000, 5)  
INSERT INTO tbl_Emp(Empid, EmpName, Gender, EmpAddress, City, Salary, Fk_DepId)VALUES(9, 'I' , 'Male', 'Demo Address', 'Noida', 5000, 1) 

  • After creating the table create the application. New -> Web Site.
  • Provide the name “DeleteRecordfromGridViewUsingJQueryAjax”.
  • Then create a new item.

Your aspx page looks likes this:

<html xmlns="http://www.w3.org/1999/xhtml"> 
    <head runat="server"> 
        <title></title> 
    </head> 
    <body> 
        <form id="form1" runat="server"> 
            <div> 
                <asp:GridView ID="gvEmp" AutoGenerateColumns="false"CellPadding="4" runat="server"> 
                    <Columns> 
                    <asp:BoundField HeaderText="EmpId" DataField="EmpId"/>
                    <asp:BoundField HeaderText="EmpName"DataField="EmpName" />

                    <asp:BoundField HeaderText="Gender" DataField="Gender" /> 
            <asp:BoundField HeaderText="EmpAddress" DataField="EmpAddress" /> 
            <asp:TemplateField> 
            <ItemTemplate> 
            <asp:HiddenField ID="hdnEmpId" runat="server" Value='<%#Eval("EmpId") %>'></asp:HiddenField>                                  <asp:LinkButton ID="btnDelete" Text="Delete Emp" runat="server"OnClientClick="DeleteConfirmbox(this.id);"></asp:LinkButton>
                         </ItemTemplate> 
                        </asp:TemplateField> 
                    </Columns> 
          <HeaderStyle BackColor="#5d5d5d" FontBold="true"ForeColor="White" />
                </asp:GridView> 
            </div> 
        </form>
         <script src="Scripts/jquery-1.7.1.min.js"></script>        
        <script type="text/javascript"> 
            function DeleteConfirmbox(val) { 
                // confirm meg check for delete 
                var result = confirm('Are you sure delete Emp Record?'); 
                if (result) {        
                  // this is for get hdnvalue id 
                  var value = val.replace("btnDelete", "hdnEmpId"); 
                  $.ajax({ 
                  type: "POST", 
                  contentType: "application/json; charset=utf-8", 
                  url: "Default.aspx/DeletegvEmpData",//this for calling the web method function in cscode. 
                  data: '{empid: "' + $("#" + value).val() + '" }',// empid value                     
                  dataType: "json", 
                  success: OnSuccess, 
                  failure: function (data) { 
                  alert(data); 
                        }          
                    });                        
                    return false; 
                } 
            }        
            // function OnSuccess 
            function OnSuccess(response) { 
                return false; 
            if (response.d == 'true') 
            {              
            }      
        } 
    </script> 
</body> 
</html> 

  • Now add “using System.Data.SqlClient;” and “using System.Data;” in the code behind and write the following code to delete the record in the grid view in the database.

protected void Page_Load(object sender, EventArgs e)  
  {  
      if (!IsPostBack)  
      {  
          Bindgv();  
      }  
  }       
  protected void Bindgv()  
  {  
      SqlConnection con = new SqlConnection("data source=LENOVO;initial catalog=practise;UID=sa;PWD=connect;");       
      con.Open();  
      SqlCommand cmd = new SqlCommand("Select Top 10 EmpId, EmpName, Gender, EmpAddress from tbl_Emp", con);  
      SqlDataAdapter da = new SqlDataAdapter(cmd);  
      DataSet ds = new DataSet();  
      da.Fill(ds);  
      con.Close();  
      gvEmp.DataSource = ds;  
      gvEmp.DataBind();       
  }       
  [System.Web.Services.WebMethod]  
  public static string DeletegvEmpData(int empid)  
  {  
      string strmsg = string.Empty;  
      SqlConnection con = new SqlConnection("data source=LENOVO;initial catalog=practise;UID=sa;PWD=connect;");       
      SqlCommand cmd = new SqlCommand("delete from tbl_Emp where EmpId= @Empid", con);       
      con.Open();  
      cmd.Parameters.AddWithValue("@Empid", empid);  
      int retval = cmd.ExecuteNonQuery();  
      con.Close();       
      if (retval == 1)  
          strmsg = "true";  
      else  
          strmsg = "false";                   
      return strmsg;  
  }
Add the jQuery library reference in aspx page:
    <script src="Scripts/jquery-1.7.1.min.js"></script> 

Finished, Now you can run this page.

TOP Recommended ASP.NET Hosting

ASPHostPortal.com is the leading provider of Windows hosting and affordable ASP.NET, ASPHostPortal proudly working to help grow the backbone of the Internet, the millions of individuals, families, micro-businesses, small business, and fledgling online businesses. Only $1.00 Month You can develop your bussines. ASPHostPortal has ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch, ASPHostPortal guarantees the highest quality product, top security, and unshakeable reliability, carefully chose high-quality servers, networking, and infrastructure equipment to ensure the utmost reliability. 

 

 



BIG DISCOUNT 70% for Windows Shared Hosting on ASPHostPortal.com

clock January 9, 2015 11:36 by author Dan

Best ASP.NET Hosting :: BIG DISCOUNT Recommendation

Good news for you are searching Best ASP.NET Hosting. ASPHostPortal.com, The Leader of ASP.NET Hosting offer BIG DISCOUNT 70% for their Windows Shared Hosting Plan. They also give uptime and 30 days money back guarantees. There are so many clients prove that ASPHostPortal give fast & stable network, and best technical support. We highly recommend you to host your site on ASPHostPortal.com.

Click the following picture to see their hosting plan. For order and more information please visit ASPHostPortal official site at http://asphostportal.com or please contact them by email at [email protected]

About ASPHostPortal.com

ASPHostPortal.com is Microsoft No #1 Recommended Windows and ASP.NET Spotlight Hosting Partner in United States. Microsoft presents this award to ASPHostPortal.com for the ability to support the latest Microsoft and ASP.NET technology, such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch.



ASP.NET Hosting - ASPHostPortal :: Tips Diagnostic And Performance Monitoring in .Net

clock January 8, 2015 06:42 by author Mark

Diagnostic And Performance Monitoring in .Net

In this article we will have a look at what is newer in .Net to help determine the problem area or scope for improvements in your program.
There are a number of tools and utilities available to monitor and tune your .Net application's performance. The .Net framework itself provides a very good infrastructure for performance monitoring and analysis.
Allows the user to monitor application domain level Memory and Processor usage statistics. Previous to .Net we had limited APIs available, which can provide support for reading only the Process level memory usage and CPU usage information. In .net you have access to Processor and Memory usage estimates for a given application domain.

The application domain based resource monitoring feature is available in:

  • Hosting APIs and
  • Event Tracing for Windows(ETW).

By default, application domain level resource monitoring is disabled. This feature has to be enabled in a process to get application domain level resouce consumption details within that process.
The AppDomain class has been enhanced to provide support for this new feature. A process can enable this feature using the AppDomain class's static property MonitoringIsEnabled.

(bool) AppDomain.MonitoringIsEnabled

It is a boolean property. Once this property is enabled in the process, it stays active until the process exits. You can assign only the value 'true'; even though it is a boolean property, assigning the value 'false' to this property causes an Invalid Argument exception.
The AppDomain class provides the following properties to access the Appdomain's resource usage.

AppDomain.MonitoringSurvivedMemorySize

It is a readonly instance property. Provides the number of bytes which is currently allocated by the Appdomain in the managed heap. In other words this property provides the size of memory which is survived the last cycle of garbage collection. This property is updated only after a full, blocking collection occurred.

AppDomain.MonitoringSurvivedProcessMemorySize

It is a readonly static property, provides the number of bytes currently allocated by the current process in the managed heap memory. This an equivalent of GC.GetTotalMemory property.

AppDomain.MonitoringTotalAllocatedMemorySize

This is a readonly instance property. It returns the total size, in bytes, of all memory allocations that have been made by the application domain since it was created, without subtracting memory that has been collected.

AppDomain.MonitoringTotalProcessorTime

It is a readonly instance property. Returns the total processor time utilized by the application domain since the process started. The total time reported by this property includes the time each thread in the process spent executing in that application domain.
The excution time of unmanaged calls made by an application domain, is also counted for that application domain.
The sleeping time of a thread is not counted in association with the application domain's processor usage.

Using Event Tracing for Windows (ETW)

You can now access the ETW events for diagnostic purposes to improve performance.



ASP.NET Hosting - ASPHostPortal.com :: Scaffolding for ASP.NET Webforms

clock January 7, 2015 05:41 by author Ben

Those who knows ASP.NET MVC, might already knows the power of scaffolding. With VS.Net 2013 we will have scaffold template included for asp.net web forms.  By scaffold template you can generate a boilerplate code for asp.net web forms in a min. The Web Forms scaffold generator can automatically build Create-Read-Update-Delete (CRUD) views based on a model.

 


Step by Step example of using scaffold template inside asp.net web forms to generate CRUD operations.

Step 1:
Download VS.Net 2013 Express Preview

Step 2:
Create Asp.net WebForm Project

Step 3:
Add Model Class and named it as "Product.cs"  (Right click Model class and Add new class)


Step 4:
Create POCO Class with following content in it.  Yes you can take advantage of DataAnnotations of Entity framework.

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;

namespace WebApplication3.Models
{
    public class Product
    {
        [ScaffoldColumn(false)]
        public int ID { get; set; }

        [StringLength(25)]  
        public string ProductName { get; set; }
        public string Description { get; set; }
       
        [DataType(DataType.Currency)]
        public int Price { get; set; }       
    }
}


In above code

  • [ScaffoldColumn(false)] will not generate any presentation code for that field
  • [StringLenght(25)] will limit product name upto 25 characters only.
  • [DataType(DataType.Currency)] will limit to enter only proper currency value.

Step 5:
Build your application.  (Cntrl + Shift + B)

Step 6:
Now its time to use scaffold template to generate code for CRUD operations in asp.net web forms.
Right click on model class and add scaffold for Product class.


Step 7:
Click on Add button as shown in figure to "Generates ASP.NET Web Forms pages for read/write operations based on a given data model."


Step 8:
Select Model class as "Product.cs", Since we haven't created or have any data context class, select "Add new data context" and Click on "Add" button.


Step 9:
If you wish you can change name of your data context class.  For this demo purpose I am keeping everything to default generated by VS.Net.  Press "OK" button.


Step 10:
You will noticed that VS.Net 2013 has generated new data context file inside model folder and has also created CRUD operations for Product class.


Step 11:
Run the application and enjoy the boilerplate code...  You will also noticed that web forms project has extension-less url and also has responsive design using Twitter bootstrap out of the box...

Type the url: /Product  notice it is extension-less url and


Click on "Create new" link and create new product

Data Entry few product.  Notice fancy validation on entering wrong values.  "Everything is out of box, you don't need to write a single line of code to make this working... Isn't that cool"


Product Listing


Similarly you can edit record, delete record. Hope you enjoyed this post...

 



ASPHostPortal.com Proudly Announces WordPress 4.1 Hosting

clock January 6, 2015 08:26 by author Dan

ASPHostPortal.com, The Best, Cheap and Recommended ASP.NET Hosting proudly announces WordPress 4.1 Hosting with a combination of affordable price, fast & stable network and uptime guarantees. ASPHostPortal.com provides full trust web hosting services for WordPress 4.1 site.

After nearly four months of development, WordPress 4.1 is available for download. WordPress 4.1 contains several improvements such as a new default theme, an improved distraction free writing experience, and plugin recommendations.

With the release of WordPress 4.1 just a few days ago, millions of people have had the opportunity to use the improved Distraction-free Writing Mode. When you enable Distraction Free Writing mode, the surrounding interface disappears as you type leaving important actions and menu items just a mouse movement away. This mode minimizes distractions without having to go through a clunky transition to access the admin menu or meta boxes. To bring back the menu and meta boxes, move the mouse cursor to the left or right of the editor.

On the Add New plugin page in WordPress 4.1, there are two different tabs to help users discover new plugins: Featured and Popular. The recommendations take into account the plugins you have installed and suggests plugins based on which ones are commonly used together. It’s similar to an e-commerce shopping cart that recommends products other customers have purchased based on what’s in the cart.

ASPHostPortal.com, a windows-based hosting service provider offers the most reliable and stable WordPress 4.1 web hosting infrastructure on the net with great features, fast and secure servers.  We has architected our network like no other hosting company. Every facet of the network infrastructure scales to gigabit speeds with no single point of failure. All of windows hosting plan supports WordPress 4.1 and customers can install WordPress 4.1 with just one click. ASPHostPortal offer professional WordPress 4.1 site start from $5/month. The following are the reasons why the customers choose and keep trust with our service:

Structured Recovery System
Recovery becomes easy and seamless with their fully managed backup services. We monitor the server to ensure customer’s data is properly backed up and recoverable so when the time comes, customers can easily repair or recover their data.

Excellent Expertise in Technology
The reason we can provide customers with a great amount of power, flexibility, and simplicity at such a discounted price is due to incredible efficiencies within our business. We have not just been providing hosting for many clients for years, we have also been researching, developing, and innovating every aspect of our operations, systems, procedures, strategy, management, and teams.

Uptime & Support Guarantees
We are so confident in their hosting services, we will not only provide you with a 30 days money back guarantee, but also give 99.9% uptime guarantee.

ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. With the WordPress 4.1 in our hosting deal will make ASPHostPortal continue to be the Best ASP.NET hosting providers. To learn more about WordPress 4.1 Hosting, please visit http://asphostportal.com/WordPress-Hosting

About ASPHostPortal.com :
ASPHostPortal.com is The Best, Cheap and Recommended ASP.NET Hosting. ASPHostPortal.com has ability to support the latest Microsoft and ASP.NET technology, such as: such as: WebMatrix, WebDeploy, Visual Studio 2015, .NET 5/ASP.NET 4.5.2, ASP.NET MVC 6.0/5.2, Silverlight 6 and Visual Studio Lightswitch. ASPHostPortal include shared hosting, reseller hosting, and sharepoint hosting, with speciality in ASP.NET, SQL Server, and architecting highly scalable solutions. ASPHostPortal.com strives to supply probably the most technologically advanced hosting solutions available to all consumers the world over. Protection, trustworthiness, and performance are on the core of hosting operations to make certain each and every website and/or software hosted is so secured and performs at the best possible level.



ASP.NET Hosting - ASPHostPortal :: How To Compare Two Images In ASP.NET

clock January 6, 2015 06:05 by author Mark

Compare Two Images In ASP.NET

This article I will explains how to compare two images in ASP.NET. You also can compare images from a database. Databases do not support binary data comparison.
For comparing two images I'm taking both images from outside but you can replace that with database also. It requires extensive conversion like byte array to image and image to bitmap. In this article I'm comparing each pixel of a bitmap.
Image comparison is not possible in any database because the binary data may not be the same. You can try it with data length also but it will not give exact result.

Using Code:

First we convert our uploaded images into a byte array for converting this byte array into images again and then this byte array are again converted into bitmap for comparison.
    byte[] _barray1;
    byte[] _barray2;

Next we have to read the bytes of uploaded images into our byte arrays like bellow. Here you can alternatively use a database field, which means here we can read the database binary data into our byte array. Here instead of reading bytes from Upload control you can read it from database.

//Reading Bytes From Uploaded Images
            if (FileUpload1.HasFile && FileUpload2.HasFile)
            {
               using(BinaryReader reader1=new BinaryReader(FileUpload1.PostedFile.InputStream))
               {
                   using (BinaryReader reader2=new BinaryReader(FileUpload2.PostedFile.InputStream))
                   {
                       _barray1 = reader1.ReadBytes(FileUpload1.PostedFile.ContentLength);
                       _barray2 = reader2.ReadBytes(FileUpload2.PostedFile.ContentLength);
                   }
               }
            }

Passing this two byte array to our compare method is not possible; for that we have to convert this byte array to images and then the images to Bitmap and pass the two bitmap to our compare method and show the results.

//Converting Byte Array To Image And Then Into Bitmap
            ImageConverter ic = new ImageConverter();
            Image img = (Image)ic.ConvertFrom(_barray1);
            Bitmap bmp1 = new Bitmap(img);
            Image img1 = (Image)ic.ConvertFrom(_barray2);
            Bitmap bmp2 = new Bitmap(img1);
            //Calling Compare Function
            if (Class1.Compare(bmp1,bmp2)==Class1.CompareResult.ciCompareOk)
            {
                Label1.Visible = true;
                Label1.Text = "Images Are Same";
            }
            else if (Class1.Compare(bmp1,bmp2)==Class1.CompareResult.ciPixelMismatch)
            {
                Label1.Visible = true;
                Label1.Text = "Pixel not Matching";
            }
            else if (Class1.Compare(bmp1,bmp2)==Class1.CompareResult.ciSizeMismatch)
            {
                Label1.Visible = true;
                Label1.Text = "Size Is Not Same";
            }

The Compare Method:

This method will perform the actual task of image comparison. This method compares each and every pixel using SHA256Managed and stores the result in enum.
public enum CompareResult
    {
        ciCompareOk,
        ciPixelMismatch,
        ciSizeMismatch
    };

    public static CompareResult Compare(Bitmap bmp1, Bitmap bmp2)
    {
        CompareResult cr = CompareResult.ciCompareOk;

        //Test to see if we have the same size of image
        if (bmp1.Size != bmp2.Size)
        {
            cr = CompareResult.ciSizeMismatch;
        }
        else
        {
            //Convert each image to a byte array
            System.Drawing.ImageConverter ic = new System.Drawing.ImageConverter();
            byte[] btImage1 = new byte[1];
            btImage1 = (byte[])ic.ConvertTo(bmp1, btImage1.GetType());
            byte[] btImage2 = new byte[1];
            btImage2 = (byte[])ic.ConvertTo(bmp2, btImage2.GetType());

            //Compute a hash for each image
            SHA256Managed shaM = new SHA256Managed();
            byte[] hash1 = shaM.ComputeHash(btImage1);
            byte[] hash2 = shaM.ComputeHash(btImage2);

            //Compare the hash values
            for (int i = 0; i < hash1.Length && i < hash2.Length && cr == CompareResult.ciCompareOk; i++)
            {
                if (hash1[i] != hash2[i])
                    cr = CompareResult.ciPixelMismatch;
            }
            shaM.Clear();
        }
        return cr;
    }

Conclusion:

This compares two images either from uploaded images or database binary data.



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

 photo ahp banner aspnet-01_zps87l92lcl.png

 

Corporate Address (Location)

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

Tag cloud

Sign in