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.NE Core 1.0 Hosting - ASPHostPortal.com :: How to Get Users IP Address in ASP.NET

clock September 5, 2016 23:20 by author Dan

Here we will learn how to get users / client IP address in asp.net using c# and vb.net with example or retrieving user's IP address in asp.net using c# and vb.net or how to get IP address of visitors machine in asp.net using c# and vb.net with example.

Description:

In previous articles I explained JavaScript Get User IP Address, City, Latitude, Longitude, how to find client machine IP using jquery in asp.net, show users current location in google map using latitude and longitude in asp.net, show google map with latitude & longitude in asp.net and many articles relating to asp.net, c#, vb.net jQuery. Now I will explain how to get users ip address or client IP address of machine in asp.net using c# and vb.net.

To get user / client ip address of machine in asp.net first create new application in visual studio then open aspx page and write the code as shown following.

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Get visitors machine IP in asp.net</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblIP" runat="server" Font-Bold="true" Font-Size="XX-Large" ForeColor="#529E00"/>
</div>
</form>
</body>
</html>


Now open code behind file and write the code like as shown below

C# Code

protected void Page_Load(object sender, EventArgs e)
{
string IPAdd = string.Empty;
IPAdd = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (string.IsNullOrEmpty(IPAdd))
IPAdd = Request.ServerVariables["REMOTE_ADDR"];
lblIP.Text = IPAdd;
}

VB.NET Code

Partial Class Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim IPAdd As String = String.Empty
IPAdd = Request.ServerVariables("HTTP_X_FORWARDED_FOR")
If String.IsNullOrEmpty(IPAdd) Then
IPAdd = Request.ServerVariables("REMOTE_ADDR")
End If
lblIP.Text = IPAdd
End Sub
End Class


If you observe above code when users ip address behind the proxies or routers then REMOTE_ADDR will return IP Address of router, not the user’s machine IP because of that first we need to check with HTTP_X_FORWARDED_FOR. In case if users machine IP address behind a proxy server then his machine’s IP Address will appended to Proxy Server’s IP Address.

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 :: How to Running Scripts Pre and Post Publish in ASP.NET Core RC2

clock August 30, 2016 20:10 by author Armend

Running Scripts Pre and Post Publish in ASP.NET Core RC2

This week I ran into an issue when deploying a Service Fabric service where a library file was not being copied to the output directory. Since I am using ASP.NET Core for my API layer in the Service Fabric project, I had to go dig around to figure out how to get the file to copy to the deployment folder during the publishing of the ASP.NET Core application.

"note that this solution with project.json may change with as ASP.NET Core moves back to .csproj file".

What I learned is that in ASP.NET Core RC 2 you can add scripts to the prepublish and postpublish events by adding a scripts section to the project.json file. In my case I needed to copy a file to the deployment folder after the rest of the project as built.

{
  "buildOptions": {
       // ...
    }
  },
  //...

  "scripts": {
    "prepublish": ["<command1>, <command2>"],
    "postpublish": [ "xcopy <pathtofile> %publish:OutputPath%" ]
  }
}

Note that you can reference variables like %publish:OutputPath%. You can also supply multiple commands by separating them with a comma. As noted above this currently works in ASP.NET Core RC2 but might change when as we transition back to the .csproj file.

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 :: Asp.net Export Excel Show/Hide Loading image

clock August 2, 2016 19:58 by author Armend

This Tip will explain how to hide the loading gif image after the file is downloaded . It  will be helpful when we are using  Response Object to export the excel or any other file format.

 

Sometimes while  downloading an excel or any file from an Asp application, it might take some time to Generate the File, the delay  depends on many factors( file size, loops, server bandwidth etc ). So we repesent the File Generation process using a rotating GIF image next to the button.
But when we are using Response object we wont get the event after the file is downloaded to the browser, in this case it will be difficult to hide the loading gif which is being shown on the screen

The below steps will guide how to  Show the Gif while Generating and hide it once the file is completly downloaded.

Hide the GIF after download

  • When the download button is clicked, show the loading gif image using onclicentClick event and CSS properties
  • On the Client click event invoke a Javascript method which Contains a  Setinterval  object that moniters  for our cookie (created in c# Response object).
  • In the Server button click Event Create an HttpCookie and append it to the Respone object.
  • So when the File is downloaded completly the Cookie is added to the Page, Now the SetInterval function will capture the cookie and Hides the Loading Gif image.
  • Note: whenever the download button is clicked, previous cookie has to be deleted.

Using the code

protected void btnExportExcel_Click(object sender, EventArgs e)
          {
            DataTable dt = new DataTable();
            dt = GetDataFromDb();
            System.Threading.Thread.Sleep(3000); // for testing purpose to create 3 seconds delay
            //Create a temp GridView
            GridView gv = new GridView();
            gv.AllowPaging = false;
            gv.DataSource = dt;
            gv.DataBind();
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=ExcelReport.xls");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-excel";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            gv.RenderControl(hw);
            // Append cookie
            HttpCookie cookie = new HttpCookie("ExcelDownloadFlag");
            cookie.Value = "Flag";
            cookie.Expires = DateTime.Now.AddDays(1);
            Response.AppendCookie(cookie);
            // end
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }

HTML/ASPX Code

<table>
            <tr>
                <td>
                    <asp:Button Text="Download" ID="btnExportExcel" OnClientClick="jsShowHideProgress();" runat="server" OnClick="btnExportExcel_Click" />
                </td>
                <td>
                    <img style="display: none" id="imgloadinggif" src="Images/loading.gif" alt="loading.." />
                </td>
            </tr>
        </table>

Javascript Code:

function jsShowHideProgress() {
    setTimeout(function () { document.getElementById('imgloadinggif').style.display = 'block'; }, 200);
    deleteCookie();

    var timeInterval = 500; // milliseconds (checks the cookie for every half second )

    var loop = setInterval(function () {
        if (IsCookieValid())
        { document.getElementById('imgloadinggif').style.display = 'none'; clearInterval(loop) }

    }, timeInterval);
}

// cookies
function deleteCookie() {
    var cook = getCookie('ExcelDownloadFlag');
    if (cook != "") {
        document.cookie = "ExcelDownloadFlag=; Path=/; expires=Thu, 01 Jan 1970 00:00:00 UTC";
    }
}

function IsCookieValid() {
    var cook = getCookie('ExcelDownloadFlag');
    return cook != '';
}

function getCookie(cname) {
    var name = cname + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') {
            c = c.substring(1);
        }
        if (c.indexOf(name) == 0) {
            return c.substring(name.length, c.length);
        }
    }
    return "";
}

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 :: Tips To Use BackgroundWorker in C#

clock July 26, 2016 19:54 by author Armend

How To Use BackgroundWorker in C#

BackgroundWorker is the class in System.ComponentModel which is used when you need to do some task on the back-end or in different thread while keeping the UI available to users (not freezing the user) and at the same time, reporting the progress of the same.

Using the Code

Backgroundworker has three event handlers which basically takes care of everything one needs to make it work.

  • DoWork - Your actual background work goes in here
  • ProgressChanged - When there is a progress in the background work
  • RunWorkerCompleted - Gets called when background worker has completed the work.

I have created a sample WPF application which demonstrates how to use the background worker in C#.

<ProgressBar x:Name="progressbar"
 HorizontalAlignment="Left" Height="14"
 Margin="191,74,0,0" VerticalAlignment="Top"
 Width="133"/>
<Button x:Name="button" Content="Button"
 HorizontalAlignment="Left"
 Margin="249,97,0,0" VerticalAlignment="Top"
 Width="75" Click="button_Click"/>

On Window initialization, I am creating a new object of BackgroundWorker and registering the event handlers for the same.

BackgroundWorker bg;
public MainWindow()
{
InitializeComponent();
bg = new BackgroundWorker();
bg.DoWork += Bg_DoWork;
bg.ProgressChanged += Bg_ProgressChanged;
bg.RunWorkerCompleted += Bg_RunWorkerCompleted;
bg.WorkerReportsProgress = true;
}

Here is the implementation of all three event handlers.

private void Bg_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
MessageBox.Show("Task completed");
}
private void Bg_ProgressChanged(object sender, ProgressChangedEventArgs e)
{
progressbar.Value += 1;
//label.Content = e.ProgressPercentage;
}
private void Bg_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 1; i &amp;lt;= 10; i++)
{
Thread.Sleep(1000); //do some task
bg.ReportProgress(0);
}
}

In order to make this stuff work, you need to trigger the DoWork event and for that, I am using button click event.

private void button_Click(object sender, RoutedEventArgs e)
   {
           progressbar.Value = 0;
           progressbar.Maximum = 10;
           bg.RunWorkerAsync();
   }

It is a very basic example of background worker, but it is good to start with. One must be wondering how it is updating the progress bar if it is working in the background.
Well, the ProgressChanged event handler runs on UI thread whereas DoWork runs on application thread pool. That's why despite running in the background on different thread, it is not freezing the UI and updating the progressbar upon making progress.

 

Best ASP.NET Core 1.0 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 :: Tips To Set Up Custom Error Pages In IIS 7.5 With ASP.NET

clock July 13, 2016 23:25 by author Armend

Tips To Set Up Custom Error Pages In IIS 7.5 With ASP.NET

If we configure .NET Error Pages at the site level, ASP.NET stores the settings in the site’s web.config file. Since these settings are stored in the web.config file they are portable and can be easily moved to another server with the site’s content.

How to setup Custom Error Pages in IIS 7.5

Open Internet Information Services (IIS) Manager.  Select your website. Note: This could also be set at the server level and applied to all sites on the server. DoubleClick on the “.NET Error Pages” icon.

The .NET Error Pages features view will be displayed.

Click the “Edit Feature Settings” link to enable this feature. The “Edit Error Page Settings” dialog box will appear.

In order to change the default mode, we must also specify a “Default Page”. This page will be used for all status codes that are  not otherwise defined. In our example we are using a generic custom error page to trap all other errors. Once you enter the absolute URL for the default error page click OK.  Note:  It may be a good idea to use a static

HTML page here just in case ASP.NET is not functioning properly.
By default server errors are shown when logged on locally to the IIS server and custom errors will only be used from remote sessions. We will want to change this to “On” if we are logged on locally to the IIS server. Otherwise, it will display detailed server errors, and not our custom error pages.

Next we will explicitly define the 404 Error code.

To get the browser to throw a 404 error, we pointed it to a file on the test site that does not exist. As you can see in the following image the friendly HTTP 404 error page was shown in IE9.
A friendly HTTP 404 Error in IE9:

On the .NET Error Pages Actions menu click the Add link.

The “Add Custom Error Page” dialog will appear. This is where we define individual error pages per status code. For our example we will add a custom page for the HTTP 404 Error.

Now that we have turned on the feature and added a custom page for the 404 status code we can verify it is working. To verify visit a page that does not exist. In our example we will use http://mysite.com/deletedfile.aspx. You can see in the following image that the custom error page was shown.
Our custom 404 Error message in IE 9

As mentioned above this can also be managed from the site’s web.config file. Consider the following configuration section from our site’s web.config file.

<configuration>
  <system.web>
    <customErrors defaultRedirect=”http://mysite.com/errors/Error.aspx” mode=”RemoteOnly”>
       <error redirect=”http://mysite.com/errors/404.aspx” statusCode=”404″ />
    </customErrors>
  </system.web>
</configuration>

Everything we set in the GUI can easily be set directly in the web.config. This will also allow you to setup .NET Error Pages, if you are on a shared hosting Plan. Here at ASPHostPortal.com, our shared, dedicated and Windows cloud server hosting plans can all benefit from using custom .NET Error Pages.




ASP.NET Core 1.0 Hosting - ASPHostPortal.com :: Easy Steps to Create FileUpload Control With Drag Drop And Progress Bar in ASP.NET

clock July 1, 2016 19:50 by author Dan

This Example explains how to use AjaxFileUpload Control With Drag Drop And Progress Bar Functionality In Asp.Net 2.0 3.5 4.0 C# And VB.NET. May 2012 release of AjaxControlToolkit includes a new AjaxFileUpload Control which supports Multiple File Upload, Progress Bar and Drag And Drop functionality. These new features are supported by Google Chrome version 16+, Firefox 8+ , Safari 5+ and Internet explorer 10 + , IE9 or earlier does not support this feature. AjaxFileUpload Control Example with Drag Drop And Progress Bar.

To start with it, download and put latest AjaxControlToolkit.dll in Bin folder of application, Place ToolkitScriptManager and AjaxFileUpload on the page.

HTML SOURCE

<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>


<asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"

                    OnUploadComplete="UploadComplete"

                    ThrobberID="loader"/>


<asp:Image ID="loader" runat="server"

           ImageUrl ="~/loading.gif" Style="display:None"/>


ThrobberID is used to display loading image instead of progress bar in unsupported browsers. Type of files uploaded can be restricted by using AllowedFileTypes property with comma separated list such as "zip,doc,pdf".

Write following code in OnUploadComplete event to save the file.

C#

protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
{
 string path = Server.MapPath("~/Uploads/") + e.FileName;
 AjaxFileUpload1.SaveAs(path);
}


VB.NET

protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
 {
string path = Server.MapPath("~/Uploads/") + e.FileName;
 AjaxFileUpload1.SaveAs(path);
}


Build and run the code.

Best ASP.NET Core 1.0 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 Core 1.0 Hosting - ASPHostPortal.com :: How to integrate those fancy modal image preview in ASP.NET

clock June 27, 2016 20:51 by author Dan

Today, in this post I will quickly show you " How to integrate those fancy modal image preview in ASP.NET ".
Magic library for this functionality is mighty FancyBox the "tool that offers a nice and elegant way to add zooming functionality for images, html content and multi-media on your webpages. It is built at the top of the popular JavaScript framework jQuery and is both easy to implement and a snap to customize."

Let's see how things are working....

  1. We create web site project inside our VS 2012.
  2. Include into project jQuery in this sample I use latest version 1.7.2.
  3. Also we need to include FancyBox. (It would be very strange to not include it in this sample)

So, our project look's like:

Here you can see our included files inside project, also you can see our test page html and jQuery code.
Most important thing here is that you use class="fancybox" as image control css class.

jQuery code is very very simple as you can see here:

       $(document).ready(function () {
            $(".fancybox").fancybox();
        });


There are more cases in how to use fancybox that you can check at FancyBox.

Effect that we managed to create looks like this:

When we click on image we get this.

So, long, folks!

Best ASP.NET Core 1.0 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 :: ASP.NET Seo Tips

clock June 21, 2016 20:41 by author Armend

When running an online business, majority of our focus is on the design, architecture of the website and how efficiently it displays our product. These are not the only things that are required to target the infinite Internet audience. One need to keep in mind that the main source of audience come from search engines such as Google, Yahoo, Bing and others. So the application or the website should be able to follow simple rules and handle your business efficiently. ASP.NET application is spreading rapidly and if you are using an ASP.NET website few simple guidelines has to be considered. The below mentioned points need to be implemented:

 

Page Titles

Page titles between tags is one important thing that many fail to practice in SEO. When a search is made in Google, these titles show up as links in the result. So that explains its importance. The common mistake among website owners is giving the same title for all pages. Page titles drive traffic to your site, hence it is important to have a proper title to attract visitors. Adding titles is not as hard as you imagine. If you have a product catalog use your product name as title. You can also choose to give a different title that is related to your product.

Meaningful URL

URLs that are long with query parameters do not look neat and it is difficult for the visitor to remember. Instead use formatted URLs for your static pages. URL which has a meaning explains the content in your website. Although experts agree with using an URL that has query parameters, it is better to have a meaningful URL. Components like UrlRewritingNet can be used for this purpose. Mapping support in URL is offered by IIS7 which has plenty of features.

Structure of the Content

Content without a structure is not possible.  You will have titles, headings, sub headings, paragraphs and others. How would you emphasize some quotes or important points in your content? If you follow the below mentioned steps, the structure of your content will be semantically correct.

  • Divide long stories or parts using headings. Short paragraphs make more sense to the readers. Use tags to bring beauty to your content.
  • If you want to emphasize an important point or quote, place them between tags.

Visitors can create structured content if you use FCKEditor and the like. Integrating these to your website is not complex.

Clean the Source Code

Don’t panic, it is advisable to clean up the source code and minimize the number of codes. The following simple steps will assist you in cleaning the source code: You can use

  •     External stylesheets and not inline CSS
  •     -js files instead of inline JavaScript
  •     HTML comments is not encouraged
  •     Avoid massive line breaking
  •     Avoid using viewstate when not required

The relation between the content and the code (JavaScript, HTML, CSS) determines the ranking of your website. Smaller source codes help build a strong relation.

Crawlable Site

Do not use

  • Silver or flash light for menus or to highlight information
  • Menus based on JavaScript
  • Menus based on buttons
  • Intro-pages

Do use

  • Simple tags wherever possible
  • Sitemap
  • “Alt” for images
  • RSS

Test the Site

What happens to the requests that are sent when the site is slow? Sometimes requests are sent by robots and if they are unable to connect to your site continuously, they drop the site from their index. Enable your site to respond fast to requests even during peak hours. Moreover, visitors don’t like to visit slow sites. Use the various tools available and conduct the stress test for your site. Perform this and locate all the weak parts of the site. Fix them so that your site gets indexed.

Test the AJAX site

Spiders can only run a few parts of your AJAX website because they don’t run JavaScripts. Spiders can only analyze the data and hence they remain invisible to robots. The AJAX sites do not get indexed which does not help in search engine optimization. To make the site spider friendly, try and keep away from initial content loading into the JavaScript. You can also follow this only for pages that you like to index.  Make it easy for robots so that they can navigate. Try this simple trick to see how your AJAX site will appear to the robots. Disable JavaScript from the browser and visit your AJAX site. You can view the pages which robots will index.

 



ASP.NET Core 1.0 Hosting - ASPHostPortal.com :: Easy Steps to Change CSS programmatically in C# ASP.NET

clock June 20, 2016 21:45 by author Dan

In this example we explain that how to change CSS dynamically from code behind in asp.net using C#. or how to change CSS file programmatically in C# code(back end  code) in asp.net.

Some time we have requirement like if user click on or check Lightweight button then Lightweight CSS is apply to the application for these user only same like if user checked or click on Professional button then Professional look is applied to the application for these user only these totally is dynamic and depend on user requirement.

So how to change or switch CSS file dynamically from code behind in asp.net using C#.

ChangeCSSFileDynamically.aspx:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ChangeCSSFileDynamically.aspx.cs"
    Inherits="WebApplication1.ChangeCSSFileDynamically" %>

<!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>Dynamically change (switch) CSS file programmatically from code behind in ASP.Net</title>
    <link id="lnkCSS" runat="server" href="~/CSS/Lightweight.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <form id="form1" runat="server">
    <asp:Label ID="Label1" runat="server" Text="This is a Label" CssClass="label"></asp:Label>
    <hr />
    <asp:RadioButton ID="chkLightWeight" runat="server" GroupName="CSSTheme" AutoPostBack="true" Text="LightWeight"
        OnCheckedChanged="chkLightWeight_CheckedChanged1" />
    <asp:RadioButton ID="chkProfessional" runat="server" GroupName="CSSTheme" AutoPostBack="true" Text="Professional"
        OnCheckedChanged="chkProfessional_CheckedChanged1" />
    </form>
</body>
</html>

ChangeCSSFileDynamically.aspx.cs:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication1
{
    public partial class ChangeCSSFileDynamically : System.Web.UI.Page
    {

        protected void chkLightWeight_CheckedChanged1(object sender, EventArgs e)
        {
            lnkCSS.Attributes["href"] = "~/CSS/Lightweight.css";
        }

        protected void chkProfessional_CheckedChanged1(object sender, EventArgs e)
        {
            lnkCSS.Attributes["href"] = "~/CSS/Professional.css";
        }
    }
}

Lightweight.css:

body
{
    font-family:Times New Roman;
    font-size:10pt;
}
.label
{
    font-weight:bold;
    color:Purple;
}

Professional.css:

body
{
    font-family:Arial;
    font-size:bold;
}
.label
{
    font-weight:bold;
    color:yellow;
}

Best ASP.NET Core 1.0 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 Core 1.0 Hosting - ASPHostPortal.com :: 7 Advantages When Using JQuery in ASP.NET

clock June 17, 2016 22:52 by author Dan

These days there are plenty of options available in case of frameworks as well as programs for the creation of webpages. One program that helps in easy scripting as well as programming is ASP.NET; jQuery gives great benefit to the program. The open source light weight JavaScript library called jQuery is a fantastic option for easy and fast HTML DOM manipulation as well as traversing, client side animations as well as scripting, event handling, etc. It also helps in easy integration of your SharePoint and ASP.Net applications. The combination of both the programs is quite intriguing which helps you create server-side dynamic websites very easily.

You can use both together very easily. Microsoft programs in fact, are bundled with jQuery so that it may be used with ASP.Net. Visual Studio is one such program which acts as the key for the creation of web pages along with coding in several languages through intellisense. In case, there is no integration between the two you simply have to download the recent jQuery library which is easily available from jQuery.com; then copy or unzip the file in the website project's root directory.

Advantages

More functionality with less writing - A huge benefit offered by this is that very less code is needed for performing of several complicated client side operations by virtue of several chaining mechanisms, selector expressions support along with other familiar features that make it easier to conduct complex DOM manipulation. The chaining mechanism helps in code reduction.

Easy, fast and lightweight -
From point of size the library is only 20KB in compressed form which makes it light, as such the execution time is less as well. When using the platform, the sheer simplicity can be easily understood. When compared to the normal JavaScript code, the development time is quite less. There are also no security risks associated; it may be included in the project simply like any JavaScript file.

Different codes than HTML mark ups - Client side scripts can be easily separated from HTML mark ups by virtue of the library. The program's $(document).ready() function enables this function. When the library is being used, the HTML code can be made neat with the combination of any JavaScript code. In fact the code can even be separated into separate file to link it to aspx page.

Cross browser compatibility -
The code is compatible with every browser which prevents any necessity for writing individual client side code meant for various browsers. When using the program to maintain cross browser compatibility, the css properties should be set so that they are compatible accordingly.

Presence of several plug-ins - The internet has several plug-ins freely available for use in the projects. There is a huge directory of plug-ins which accounts for the high jQuery usage which is growing each day. In fact, many of the available plug-ins may be re-used.

Lightweight and easy Ajax application -
A huge advantage of using the library lies in the development of light weight Ajax application with JSON support in ASP.Net. The library helps in prevention of bulky UpdatePanel control meant for Ajax communications.

Use of Content Distribution Network for internet sites - For the sites which are hosted on internet, the using of library hosted by Google CDN becomes easy. Major open source widely used JavaScript libraries are used globally across sites by virtue of the network. This helps in the management of recent updates, bug fixes as well as provision of high speed access for better caching.

Other advantages are easy integration between jQuery and ASP.NET Ajax projects and extension of existing functionality. In fact, the benefits do not simply stop with those mentioned here. When the platform is actually used, then only you will be able to understand a lot more points. There are no security risks associated with the usage which gives yet another benefit to the developers.

You can hire developers from top asp.net application development companies in India who can help you build web applications according to your ideas within allocated budget and time schedules.

Best ASP.NET Core 1.0 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