Tag Archives: reliable asp.net hosting

ByAlexia Pamelov

How to Convert DataTable To JSON String in ASP.NET

CheapWindowsHosting.com | Best and cheap ASP.NET Hosting. First of all you need to create an “ASP.NET Empty Web Site”. Then use the following procedure.

Affiliate-program-01-1

Step 1

Create a ConvertDataTableToJson class in the App_Code folder and provide the following:

Convert DataTable To JSON String.       
    using System.Data 
    using System.Text; 
    public class ConvertDatatableToJson 
    { 
       public string DataTableToJson(DataTable dt) 
       { 
          DataSet ds = new DataSet(); 
          ds.Merge(dt); 
          StringBuilder JsonStr = new StringBuilder(); 
          if (ds != null && ds.Tables[0].Rows.Count > 0) 
          { 
             JsonStr.Append("["); 
             for (int i = 0; i < ds.Tables[0].Rows.Count; i++) 
             { 
                JsonStr.Append("{"); 
                for (int j = 0; j < ds.Tables[0].Columns.Count; j++) 
                { 
                   if (j < ds.Tables[0].Columns.Count - 1) 
                   { 
                      JsonStr.Append("\"" + ds.Tables[0].Columns[j].ColumnName.ToString() + "\":" + "\"" + ds.Tables[0].Rows[i][j].ToString() + "\","); 
                   } 
                   else if (j == ds.Tables[0].Columns.Count - 1) 
                   { 
                      JsonStr.Append("\"" + ds.Tables[0].Columns[j].ColumnName.ToString() + "\":" + "\"" + ds.Tables[0].Rows[i][j].ToString() + "\""); 
                   } 
                } 
                if (i == ds.Tables[0].Rows.Count - 1) 
                { 
                   JsonStr.Append("}"); 
                } 
                else    
                { 
                   JsonStr.Append("},"); 
                } 
             } 
             JsonStr.Append("]"); 
             return JsonStr.ToString(); 
          } 
          else 
          { 
             return null; 
          } 
       }

Step 2

Insert the grid view control into the Default.aspx page then write the following design code:

<asp:GridView ID="ui_grdVw_EmployeeDetail" runat="server" Width="50%" AutoGenerateColumns="false" HeaderStyle-CssClass="pageheading"> 
    <Columns> 
    <asp:TemplateField HeaderText="S.NO"> 
    <ItemTemplate> 
    <%#Container.DataItemIndex+1 %> 
    </ItemTemplate> 
    </asp:TemplateField> 
    <asp:TemplateField HeaderText="Employee ID"> 
    <ItemTemplate> 
    <asp:Label ID="ui_lbl_EmployeeID" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Emp_id") %>'></asp:Label> 
    </ItemTemplate> 
    </asp:TemplateField> 
    <asp:TemplateField HeaderText="Employee Name"> 
    <ItemTemplate> 
    <asp:Label ID="ui_lbl_EmployeeName" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Emp_Name") %>'></asp:Label> 
    </ItemTemplate> 
    </asp:TemplateField> 
    <asp:TemplateField HeaderText="Employee Post"> 
    <ItemTemplate> 
    <asp:Label ID="ui_lbl_EmpJob" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Emp_job") %>'></asp:Label> 
    </ItemTemplate> 
    </asp:TemplateField> 
    <asp:TemplateField HeaderText="Department"> 
    <ItemTemplate> 
    <asp:Label ID="ui_lbl_Department" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Emp_Dep") %>'></asp:Label> 
    </ItemTemplate> 
    </asp:TemplateField> 
    </Columns> 
    </asp:GridView> 
    <br /> 
    <asp:Button ID="ui_btn_Convert1" runat="server" Text="Manually Convert To Json" OnClick="ui_btn_Convert1_Click" /><br /><br /><br /> 
    <asp:Label ID="ui_lbl_JsonString1" runat="server"></asp:Label>

Step 3

Now, open the Deafult.asps.cs then write the following code:

using System; 
   using System.Data; 
   public partial class _Default : System.Web.UI.Page 
   { 
      #region Global Variable 
      DataTable dt; 
      ConvertDatatableToJson dtJ; 
      string JsonString = string.Empty;    
      #endregion 
       
      protected void Page_Load(object sender, EventArgs e) 
      { 
         if (!IsPostBack) 
         { 
            ui_grdvw_EmployeeDetail_Bind(); 
         } 
      }       
      protected void ui_grdvw_EmployeeDetail_Bind() 
      { 
         dt = new DataTable(); 
         EmployeeRecord employeeRecord = new EmployeeRecord(); 
         dt = employeeRecord.EmpRecord(); 
         ViewState["dt"] = dt; 
         ui_grdVw_EmployeeDetail.DataSource = dt; 
         ui_grdVw_EmployeeDetail.DataBind(); 
      }       
      protected void ui_btn_Convert1_Click(object sender, EventArgs e) 
      { 
         dtJ = new ConvertDatatableToJson(); 
         JsonString = dtJ.DataTableToJson((DataTable)ViewState["dt"]); 
         ui_lbl_JsonString1.Text = JsonString; 
      } 
   }

Step 4

Press F5, run the project.

Now, convert the DataTable to a JSON string using the newtonsoft DLL.

Step 1

Download the Newtonsoft DLL and move it to the ASP.Net project’s bin folder.

Step 2

Then, insert a button and label UI Control in the Deafult.aspx page as in the following:

<asp:Button ID="iu_btn_Convert2" runat="server" Text="Newtonsoft Convert To Json" OnClick="iu_btn_Convert2_Click" /> 
    <br /> 
    <br /> 
    <asp:Label ID="ui_lbl_JsonString2" runat="server"></asp:Label>

Step 3

Now, write the following code in Default.aspx.cs:
using this namespace

using Newtonsoft.Json;

 And then:

protected void iu_btn_Convert2_Click(object sender, EventArgs e) 
    { 
       dt = (DataTable)ViewState["dt"]; 
       JsonString = JsonConvert.SerializeObject((DataTable)ViewState["dt"]); 
       ui_lbl_JsonString2.Text = JsonString; 
    }

 Now, run the project and click on the Newtonsoft Convert to JSON .

Best OFFER Recommended ASP.NET Hosting ! Click Here

ByAlexia Pamelov

How to Increase The Overall Performance of ASP.NET in your App

CheapWindowsHosting.com | Best and cheap ASP.NET hosting. ASP.NET is really a framework for creating net applications created by Microsoft. Initially the technologies. NET is the successor of ASP which is also a computer software product from Microsoft. With .NET ASP gives a platform for developers to design and create dynamic websites and net portals.

112414-websecurity-850x476

You will find certain items that ought to be regarded as when improving the performance from the application in developing a net application. Here are a few of the tips to improve the performance of ASP.NET 4.5.1:

Turn off Session State

Disable session state if you do not need, as this can improve the all round efficiency. By default the session state is always active. However, you’ll be able to disable session state for any specific pages.

Turn off Tracing

If tracing is enabled, tracing will add a whole lot of overhead in producing applications. Though tracing is actually a useful function inside the development because it enables developers to track and trace application sequence, tracing may be turned off, unless you want to monitor the trace logging.

Avoid Page Validation Server (Steer clear of Server-side Validation)

Within this case, must be attempted use of client-side validation, not the server side. Server-side validation will consume a lot of sources around the server which can have an effect on application efficiency.\

Stay away from Exceptions (Avoid Exceptions)

Exceptions may be 1 of the biggest resource eater which resulted within the lower of web applications and windows applications. Therefore, it is much better to prevent the use and handling of exceptions which can be not beneficial.

Avoid frequent connections for the database (Steer clear of Frequent Calls to Database)

Connections are frequently made for the database can devote time response and resources (resources). This can be avoided by utilizing batch processing. Producing the minimum database connection as a connection is opened and not closed, may cause efficiency slowdown.

Stay away from utilizing Recursive Functions and Nested Loops

To improve application performance, attempt to always steer clear of utilizing nested loops and recursive functions simply because these functions consume a whole lot of memory.

Turn off the View State

In ASP.NET, the default view state will probably be active and will slow down the website. So if you don’t use a kind postback, it’s much better to disable view state.

Use Caching

Web page caching could be employed to get a particular period of time and towards the required duration will not visit the server and are served from the cache. In the case of static internet pages and dynamic, Partial Caching [Fragment Caching] may be utilized to break into a couple of pages a user control.

Best OFFER Recommended ASP.NET Hosting ! Click Here

ByAlexia Pamelov

Cheap Windows ASP.NET Hosting – Tips You Shall Know on Choosing ASP.NET Hosting

CheapWindowsHosting.com | Best and cheap ASP.NET Hosting. Being devoted into ASP.NET development and ASP.NET website hosting for a couple of years, we know the secrets hidden in the ASP.NET hosting advertisement and how difficult to find a trusted and cost effective ASP.NET hosting provider. Thus, we would like to show you the top 10 tips on choosing ASP.NET hosting providers before starting with our topic.

  1. MS SQL Server database edition and limitation. The latest version of MSSQL 2012 are preferred.
  2. .NET Framework versions. Does it support the version used for your website?
  3. ASP.NET MVC versions. Does it support the version used for your website if you’re using ASP.NET MVC technology?
  4. Does it provide the dedicated application pool so that you won’t be affected by your neighbors?
  5. How long the IIS is set to recycle your website – usually 30 minutes at least is required.
  6. What’s the maximum dedicated memory allowed for the ASP.NET websites?
  7. The hosting provider needs to have the rich experiences and knowledge of how to ensure the high-quality ASP.NET hosting. Besides, it is great that they have got plenty of positive feedbacks from real customers and have been trusted and recommended by a lot of authorities, communities and hosting review sites.
  8. The ASP.NET hosting needs to ensure a high level of hosting reliability with at least 99.9% uptime. Note that this can be achieved with the utilization of cutting-edge data centers, solid server machines and no overselling practice. In addition, some confident web hosts even claim to give you some compensations if they fail to meet their promised uptime track record.
  9. The hosting speed is also pretty essential. After all, your readers can be frustrating if they find it takes a long time for accessing your website. In this case, you need to figure out that whether your web host can ensure the peak performance with no more than 3 seconds for page loading and 400 ms for the server response.
  10. The web host needs to ensure the all-time-rounded technical support to assist you 24 hours a day and 7 days a week. Also, their support staffs need to have the rich knowledge about ASP.NET hosting and related applications.

General Knowledge about ASP.NET

ASP.NET is the server-side online application framework coming with the open source nature. It is designed with the purpose of web development and dynamic webpages production mainly. In addition, developed by Microsoft, ASP.NET has been used by a lot of programmers for the creation of complicated websites, online applications and add-on services.

In fact, ASP.NET has been released since January 2002, which is the successor to the Active Server Pages technology of Microsoft. As it is built based on the Common Language Runtime, developers and programmers can write the ASP.NET code with the help of .NET language.

Cheap Windows ASP.NET Hosting

ASPHostPortal  Cheap Windows ASP.NET Hosting

Why we choose ASPHostPortal for the cheap ASP.NET hosting ?

ASPHostPortal.com, a Microsoft Golden hosting partner has been offering well priced Windows and ASP.NET hosting plans for many years. Founded in 2008 and operated in New York, US. ASPHostPortal.com has become an important resource for cutting-edge, high-value hosting solutions. The company also offers low priced enterprise-level hosting plans by focusing their resources on needs by ASP.NET Windows’s developers.

This company supports almost all the latest ASP.NET technology and provides plenty of server resources for every hosting account. Below are the list of key features, but definitely it provides more:

aspportalASPHostPortal.com | The cheap ASP.NET  Hosting Provider. Cheap and affordable Hosting features including:

ASPHostPortal.com


  1. Unlimited Sites, 5 GB Disk Space,  60 GB Bandwidth only $ 5.00/Mo
  2. IIS 8.5 with URL-Rewrite, ASP.NET MVC Framework.
  3. Compatible with nopCommerce, DNN, Magento and more other ASP.NET web applications.
  4. 100% Satisfaction Promise with 30 Days Money Back Guarantee!

HostForLIFE  Affordable ASP.NET  Hosting

hflHostForLIFE.eu | Professional ASP.NET Provider & fully ASP.NET support. Customers can easily deploy the most popular ASP.NET, CMS & Blog system such as BlogEngine, DotNetNuke. The best ASP.NET hosting feature including :

HostForLIFE.eu


  1. Unlimited Domain, Unlimited Disk Space, Unlimited Bandwidth only €3.00/Mo
  2. IIS 8.5 with URL-Rewrite, ASP.NET MVC Framework.
  3. 100% Satisfaction Promise with 30 Days Money Back Guarantee!

 UKWindowsHostASP.NET Best ASP.NET  Hosting

ukwinhostUKWindowsHostASP.NET | The best ASP.NET Provider & fully ASP.NET support. One of top and recommended ASP.NET Hosting Providers ! ASP.NET Hosting feature plan including:
 

  1. Unlimited Domains
  2. Dedicated Pool
  3. 99.99% Uptime Guarantee & 24/7 Live Support
  4. Support WordPress, Drupal and etc
  5. FREE Instant Setup
ByAlexia Pamelov

Cheap Windows ASP.NET Hosting – Tips Increase Your ASP.NET Performance for SEO

CheapWindowsHosting.com | Best and cheap ASP.NET hosting. In this post we will explains you about Increase Your ASP.NET Performance for SEO. Lets check it out.

programmer vs artist

A challenge faced by web developers and designers is creating engaging, responsive, interactive web pages that load quickly and keep the user happy.  With high performance site, then our site will be ranked higher by Google. In this tutorial, I will show some tips how to increase your site performance in ASP.NET. The better ranking most likely lead to more click throughs, increasing the website’s visibility, audience, and profit.

Increasing ASP.NET performance for SEO

I have been using ASP.NET programming language for many years and I always learn how to increase my asp.net speed. With great ASP.NET performance, then it will increase our website visibility, audience, and profit. And google like the site with high performance. Here are few tips from me how to increase your ASP.NET performance:

1. Disable Session State

Disable Session State if you’re not going to use it.  By default it’s on. You can actually turn this off for specific pages, instead of for every page:

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
AutoEventWireup="false" Inherits="WebApplication1.WebForm1"
EnableSessionState="false" %>

 

You can also disable it across the application in the web.config by setting the <sessionState> mode value to Off.

2. Avoid Server-Side Validation

Try to avoid server-side validation, use client-side instead. Server-Side will just consume valuable resources on your servers, and cause more chat back and forth.

3. Use HTTPServerUtility.Transfer instead of Response.Redirect

Redirect’s are also very chatty.  They should only be used when you are transferring people to another physical web server.  For any transfers within your server, use .transfer!  You will save a lot of needless HTTP requests.

4. Turn off Tracing

Tracing is awesome, however have you remembered to turn it off? If not, make sure you edit your web.config and turn it off!  It will add a lot of overhead to your application that is not needed in a production environment.

<configuration>
<system.web>
<trace enabled="false" pageOutput="false" />
<trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/>
<compilation debug="false" />
</system.web>
</configuration>

5. Avoid Exceptions

Avoid throwing exceptions, and handling useless exceptions. Exceptions are probably one of the heaviest resource hogs and causes of slowdowns you will ever see in web applications, as well as windows applications.  Write your code so they don’t happen!  Don’t code by exception!

6. Turn Off ViewState

If you are not using form postback, turn off viewsate, by default, controls will turn on viewsate and slow your site.

public ShowOrdersTablePage()
{
this.Init += new EventHandler(Page_Init);
}

private void Page_Init(object sender, System.EventArgs e)
{
this.EnableViewState = false;
}

 

7. Use Paging

Take advantage of paging’s simplicity in .net. Only show small subsets of data at a time, allowing the page to load faster.  Just be careful when you mix in caching. How many times do you hit the page 2, or page 3 button?  Hardly ever right!  So don’t cache all the data in the grid! Think of it this way: How big would the first search result page be for “music” on Google if they cached all the pages from 1 to goggle

8. Use ControlState and not ViewState for Control

If you followed the last tip, you are probably freaking out at the though of your controls not working.  Simply use Control State. 

Conclusion

There are hundreds more where these came from, however I really feel that these are the most critical of the speed improvements you can make in ASP.net that will have a dramatic impact on the user experience of your application. If you find benefits on this article, please kindly share it!

Best OFFER Cheap ASP.NET 5 Hosting ! Click Here

ByAlexia Pamelov

Cheap Windows Hosting tutorial – How to pass parameters to Silverlight controls from ASP.NET pages ?

CheapWindowsHosting.com | In this post we will explain you about How to pass parameters to Silverlight controls from ASP.NET pages ? You can pass parameters from your aspx pages and html pages to the Silverlight controls. This chapter explains how to pass parameters to Silverlight controls from your aspx page and code behind files.

CustomerService-

InitParameters

The Xaml page user control has a property called InitParameters. You can set a value in the form of key-value pairs from your ASPX pages. Since this property accepts key-value pairs, you can pass any set of string values.

How to set InitParameters

Example – Set InitParameters property from ASPX page:

<asp:Silverlight 
   ID="Xaml1" 
   runat="server" 
   Source="~/ClientBin/MySilverlightApp.xap" 
   InitParameters="City=Houston,State=Texas,Country=USA"
   Width="300" 
   Height="300" />

You can set this property from the code behind file of your ASPX page as well.
Example – Set InitParameters property from the code behind file:

Xaml1.InitParameters = "City=Houston,State=Texas,Country=USA";

How to retrieve the InitParameters value ?

The value you pass to a Silverlight control through the InitParameters property can be retrieved from the Application_Startup even handler in the App.xaml page.

private void Application_Startup(object sender, StartupEventArgs e)
{
    IDictionary<string, string=""> parameters = e.InitParams;
    this.RootVisual = new Page1();

Now, in most cases, you may want to pass this value to the xaml page itself instead of doing anything with in it the App.xaml.

Pass parameters from App.xaml to other pages

To pass the parameters from the App.xaml pages to other pages, you must modify the constructor of xaml page class to accept parameters.

private IDictionary<string, string> parameters = null;
public Page1()
{
    InitializeComponent();
}
public Page1(IDictionary<string, string> p)
{
    this.parameters = p;
    InitializeComponent();
}

The above sample shows an additional constructor added which takes a parameter of type IDictionary and then sets the value to a member variable.

Now go back to your App.xaml and pass the parameters to the page:

private void Application_Startup(object sender, StartupEventArgs e)
{
    IDictionary<string, string=""> parameters = e.InitParams;
    this.RootVisual = new Page1(parameters);

Use the IDictionary parameter values in the XAML pages

If you have followed the above steps correctly, you should be able to access the IDictionary values in your XAML page.

textblock1.Text = this.parameters["City"];

Here is the complete code from the XAML page:

<UserControl x:Class="MySilverlightApp.Page1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    Width="400" Height="300" Loaded="UserControl_Loaded">
    <Grid x:Name="LayoutRoot" Background="White">
<TextBlock x:Name="textblock1" Width="200" Height="30"></TextBlock>
    </Grid>
</UserControl>

In the code behind file for your page1.xaml, you can set the Text for the textblock1 control as shown below:

private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
        textblock1.Text = parameters["City"];

  Best OFFER Cheap SilverLight 6 Hosting ! Click Here

 

 

Simpan

Simpan