European ASP.NET 4.5 Hosting BLOG

BLOG about ASP.NET 4, ASP.NET 4.5 Hosting and Its Technology - Dedicated to European Windows Hosting Customer

ASP.NET Core 1.0 Hosting - HostForLIFE.eu :: How to Read a Remote WEB Page in ASP.NET C#?

clock October 26, 2016 09:15 by author Peter

In this tutorial, let me show you how to Read a Remote WEB Page in ASP.NET C#. Below is my aspx:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
     
    <!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></title> 
    </head> 
    <body> 
        <form id="form1" runat="server"> 
        <div> 
            <asp:Label ID="lblResponse" runat="server"></asp:Label></div> 
        </form> 
    </body> 
    </html> 

Now my aspx.cs is:

    using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.UI; 
    using System.Web.UI.WebControls; 
    using System.Net; 
    using System.IO; 
     
    public partial class _Default : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
            string URLResponse = GetHtmlPage("http://www.google.com"); 
            lblResponse.Text = URLResponse; 
        } 
     
        static string GetHtmlPage(string strURL) 
        { 
     
            String strResult; 
            WebResponse objResponse; 
            WebRequest objRequest = HttpWebRequest.Create(strURL); 
            objResponse = objRequest.GetResponse(); 
            using (StreamReader sr = new StreamReader(objResponse.GetResponseStream())) 
            { 
                strResult = sr.ReadToEnd(); 
                sr.Close(); 
            } 
            return strResult; 
        } 
    } 


Here I am reading http://www.google.com and showing response in a label:

 


HostForLIFE.eu ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



European ASP.NET Core 1.0 Hosting - HostForLIFE.eu :: Setup Angular 2 in ASP.NET Core 1.0

clock October 12, 2016 00:11 by author Scott

This tutorial aims for starting Angular 2 in ASP.NET Core using Visual Studio 2015. The release of Angular 2, ASP.NET Core RC is becoming interesting to build SPA.

I have compiled the steps involved in starting to learn Angular 2. This is detailed explanation, you will feel much easier at end of article.

Create Your ASP.NET Core Project

Open Visual Studio 2015 Community Edition Update 3, Select New Web Project naming it “ngCoreContacts” and select “Empty” project template. Don’t forget to install new web tools for ASP.NET Core 1.0

I used Visual Studio 2015 Community Edition Update 3(Must update), TypeScript 2.0 (must), latest NPM, Gulp.

Setup ASP.NET Core to Serve Static Files

ASP.NET Core is designed as pluggable framework to include and use only necessary packages, instead of including too many initial stuff.

Lets create HTML file named “index.html” under wwwroot folder.

Right click on wwwroot folder, Add New Item and create index.html file. This HTML page will act as default page.

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <title>Angular 2 with ASP.NET Core</title>
</head>
<body>
    <h1>Demo of Angular 2 using ASP.NET Core with Visual Studio 2015</h1>
</body>
</html>

For ASP.NET Core to serve static files, we need to add StaticFiles middle ware in Configure method of Startup.cs page. Ensure that packages are restored properly.

project.json is redesigned to make it better, we have Static Files middleware to serve static assets like HTML, JS files etc.

public void Configure(IApplicationBuilder app)
        {
            app.UseDefaultFiles();
            app.UseStaticFiles();
        }

 

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true,
    "compile": {
      "exclude": [ "node_modules" ]
    }
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "web.config"
    ]
  },

  "scripts": {   
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

Run the application now, ASP.NET Core renders static HTML page.

Delete this index.html page, we will be injecting this dynamically later. Till now you saw demonstration of “wwwroot“ as root folder for ASP.NET Core web apps.

Setup Angular 2 in ASP.NET Core

Angular 2 is famously claiming to be ONE Framework for MOBILE and DESKTOP apps. There’s won’t be any breaking changes after final release.

This tutorial refers 5 MIN QUICK START for getting started, it’s more focused on other light weight code editors; but here we are using Visual Studio 2015 Community Edition Update 3 for its built in TypeScript tooling and other features.

We will be using Webpack for module bundler, it’s an excellent alternative to the systemJS approach. To know more about inner details of read “webpack and Angular 2

Majority of webpack scripting is based on AngularClass’s angular2-webpack-starter. I have modified according to ASP.NET Core web apps.

Adding NPM Configuration file for Angular 2 Packages

Angular 2 team is pushing the code changes using NPM rather than CDN or any other source, due to this we need to add NPM configuration file (package.json) to this ASP.NET Core application.

Right Click on “ngCoreContacts“, add new file “NPM Configuration File“; by default package.json is added to ASP.NET Core project. This acts Node Package Manager (NPM) file, a must for adding packages for Angular 2

From the Angular 2 Quick start provided above, we need to add dependencies for required for Angular 2 in ASP.NET Core application. Copy Paste below configuration in package.json file

{
    "version": "1.0.0",
    "description": "ngcorecontacts",
    "main": "wwwroot/index.html",
  "scripts": {
    "build:dev": "webpack --config config/webpack.dev.js --progress --profile",   
    "build:prod": "webpack --config config/webpack.prod.js  --progress --profile --bail",
    "build": "npm run build:dev",   
    "server:dev:hmr": "npm run server:dev -- --inline --hot",
    "server:dev": "webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base clientsrc/",
    "server:prod": "http-server dist --cors",
    "server": "npm run server:dev",
    "start:hmr": "npm run server:dev:hmr",
    "start": "npm run server:dev",
    "version": "npm run build",
    "watch:dev:hmr": "npm run watch:dev -- --hot",
    "watch:dev": "npm run build:dev -- --watch",
    "watch:prod": "npm run build:prod -- --watch",
    "watch:test": "npm run test -- --auto-watch --no-single-run",
    "watch": "npm run watch:dev",   
    "webpack-dev-server": "webpack-dev-server",
    "webpack": "webpack"
  },
  "dependencies": {
    "@angular/common": "~2.0.1",
    "@angular/compiler": "~2.0.1",
    "@angular/core": "~2.0.1",
    "@angular/forms": "~2.0.1",
    "@angular/http": "~2.0.1",
    "@angular/platform-browser": "~2.0.1",
    "@angular/platform-browser-dynamic": "~2.0.1",
    "@angular/router": "~3.0.1",
    "@angular/upgrade": "~2.0.1",
    "angular-in-memory-web-api": "~0.1.1",
    "@angularclass/conventions-loader": "^1.0.2",
    "@angularclass/hmr": "~1.2.0",
    "@angularclass/hmr-loader": "~3.0.2",
    "@angularclass/request-idle-callback": "^1.0.7",
    "@angularclass/webpack-toolkit": "^1.3.3",
    "assets-webpack-plugin": "^3.4.0",
    "core-js": "^2.4.1",
    "http-server": "^0.9.0",
    "ie-shim": "^0.1.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "~0.6.17",
    "@angular/material": "^2.0.0-alpha.9",
    "hammerjs": "^2.0.8"
  },
  "devDependencies": {
    "@types/hammerjs": "^2.0.33",
    "@types/jasmine": "^2.2.34",
    "@types/node": "^6.0.38",
    "@types/source-map": "^0.1.27",
    "@types/uglify-js": "^2.0.27",
    "@types/webpack": "^1.12.34",
    "angular2-template-loader": "^0.5.0",
    "awesome-typescript-loader": "^2.2.1",
    "codelyzer": "~0.0.28",
    "copy-webpack-plugin": "^3.0.1",
    "clean-webpack-plugin": "^0.1.10",
    "css-loader": "^0.25.0",
    "exports-loader": "^0.6.3",
    "expose-loader": "^0.7.1",
    "file-loader": "^0.9.0",
    "gh-pages": "^0.11.0",
    "html-webpack-plugin": "^2.21.0",
    "imports-loader": "^0.6.5",
    "json-loader": "^0.5.4",
    "parse5": "^1.3.2",
    "phantomjs": "^2.1.7",
    "raw-loader": "0.5.1",
    "rimraf": "^2.5.2",
    "source-map-loader": "^0.1.5",
    "string-replace-loader": "1.0.5",
    "style-loader": "^0.13.1",
    "sass-loader": "^3.1.2",   
    "to-string-loader": "^1.1.4",
    "ts-helpers": "1.1.1",
    "ts-node": "^1.3.0",
    "tslint": "3.15.1",
    "tslint-loader": "^2.1.3",
    "typedoc": "^0.4.5",
    "typescript": "2.0.3",
    "url-loader": "^0.5.7",
    "webpack": "2.1.0-beta.22",
    "webpack-dev-middleware": "^1.6.1",
    "webpack-dev-server": "^2.1.0-beta.2",
    "webpack-md5-hash": "^0.0.5",
    "webpack-merge": "^0.14.1"
  }
}

Right after saving this, ASP.NET Core starts restoring the packages. It would download all packages mentioned independencies section of above package.json.

Sometimes in solution explorer you might see ‘Dependencies – not installed’, don’t worry this bug in tooling. All the npm packages are installed.

Add TypeScript configuration file – must for Angular 2 in ASP.NET Core using TypeScript

We are creating Angular 2 in ASP.NET Core starting with TypeScript, this obvious reason adds to include TypeScript Configuration file which does work of transpiling it to JavaScript, module loading, target ES5 standards.

Add “tsconfig.json” in the project, copy paste below configuration.

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "noEmitHelpers": true,
    "strictNullChecks": false,
    "baseUrl": "./clientsrc",
    "paths": [],
    "lib": [
      "dom",
      "es6"
    ],
    "types": [
      "hammerjs",     
      "node",     
      "source-map",
      "uglify-js",
      "webpack"
    ]
  },
  "exclude": [
    "node_modules",
    "dist"
  ],
  "awesomeTypescriptLoaderOptions": {
    "forkChecker": true,
    "useWebpackText": true
  },
  "compileOnSave": false,
  "buildOnSave": false,
  "atom": { "rewriteTsconfig": false }
}

It’s mandatory to install TypeScript 2.o for working with Angular 2.

At present typings.json is not required because we are using @types with TypeScript. However if your using any other packages which don’t have entries in @types then typings.json has to be added.

Use Webpack as Module Bundler

Webpack is a powerful module bundler. A bundle is a JavaScript file that incorporate assets that belong together and should be served to the client in a response to a single file request. A bundle can include JavaScript, CSS styles, HTML, and almost any other kind of file.

Webpack roams over your application source code, looking for import statements, building a dependency graph, and emitting one (or more) bundles. With plugin “loaders” Webpack can preprocess and minify different non-JavaScript files such as TypeScript, SASS, and LESS files.

In package.json, we have added “webpack“ packages as “devdependencies“. They will perform all bundling work.

What webpack does is written in a JavaScript configuration file know as webpack.config.js. As always the applications are run in Development, Test and Production environment.

There are some common functionalities and some specific to environments. We will focus on development and productionenvironment to write accordingly.

Development environment should have source maps for debugging TypeScript files, minifying bundles of JS, CSS etc files not necessary.

Production environment should minify bundles to reduce loading time, do not include source maps. Webpack 2 also does tree shaking i.e. eliminate unused code to further reduce bundle sizes.

webpack.config.js – Based on environment set process.env.NODE_ENV, it runs either dev or prod configurations.

Webpack.common.js before bundling environment specific files, it performs tasks meant to be used for both environment.

  • Webpack splits Angular 2 apps into 3 files polyfills(to maintain backward compatibility with older browsers) , vendors(all JS, CSS, HTML, SCSS, images, JSON etc into one file) and boot (application specific files)
  • resolve based on various file extensions
  • Webpack itself doesn’t know what to do with a non-JavaScript file. We teach it to process such files into JavaScript withloaders. For this, we have written loaders TS, HTML, JSON, Fonts, images
  • Any static assets placed in “clientsrc/assets” will be copied to assets folder using CopyWebpackPlugin
  • CleanWebpackPlugin cleans “wwwroot/dist” folder every time we run it, so that we get fresh set of files.
  • I told you above to delete the index.html file, now the clientsrc/index.html will be moved to wwwroot usingHtmlWebpackPlugin. Plus Webpack injects the bundle files i.e. polyfills, vendor, boot JS files and includes them in HTML script reference.

Now let’s see webpack.dev.js for development purpose

  • Running “webpack-dev-server” – this runs entire application in memory, any changes to source file gets applied immediately
  • Loads application in debug mode with source map. Everything run in memory i.e. html, js, static files are loaded in memory.
  • Runs the application on localhost 3000 port. Port can be changed as your convenience

Now let’s see webpack.prod.js for production purpose

  • Merges all the bundle files and copies to wwwroot.
  • Minifies all files to load faster using UglifyJsPlugin plugin

Writing Angular 2 application

Until now we created ASP.NET Core app, added TSconfig file, webpack configuration. Now it’s time to write Angular 2 application

In the github repo, you can see “clientsrc” folder. This contains the angular 2 app which gets bundled into using webpack configurations we wrote

“Clientsrc“ folder has index.html, polyfills.browses.ts, vendor.browsers.ts and mostly importantly boot.ts

We have app folder containing HTML, Angular 2 components and root level module (app.module.ts) which gets loaded while bootstrapping application.

Some of files might be not interesting now, will focus them in separate articles later.

Running the application

Before running make sure you have run command “npm install”. This might not be needed but still it will ensure all packages are installed.

Now let’s run the application in development mode

  • From command line (directory should be same as package.json), type “npm start” & hit enter. It will start running the webpack-dev-server which loads application and listens on localhost:3000.
  • When on console it says “bundle is now VALID” then open a browser and navigate to http://localhost:3000 to see application getting loaded.

Notice wwwroot folder, we don’t see any files copied because everything is running in memory.

Now that application runs properly on browser, let’s understand how Angular 2 app loads

  • When browser starts rendering index.html page, it encounters <my-app>Loading…</my-app> tag.
  • Then Angular’s module platformBrowserDynamic bootstraps clientsrc/app/AppModule through lineplatformBrowserDynamic().bootstrapModule(AppModule)
  • AppModule then loads the component app.component.ts which is mentioned in @NgModule as bootstrap entry
  • Clientsrc/src/Appcomponent then resolves the <my-app> tag as selector in it and renders UI with TypeScript code.

When we enter “npm start” in console to run the application, execution points scripts section of package.json to below code

webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base clientsrc/

This invokes webpack-dev-server, runs the development config and watches for any changes in clientsrc folder. Any changes in this folder will reload application with changes.

Running the application in Production mode

Assuming the application is now ready to deployed, we need to have PROD build. For this run command

//builds app and copies in wwwroot
Npm run build:prod

Now if you see wwwroot folder, we see the HTML, JS bundle files. This wwwroot folder can be deployed on any web server like IIS or nginx

You can either do F5 to run from Visual Studio IDE or run command npm run server:prod



ASP.NET Core 1.0 Hosting - HostForLIFE.eu :: Showing Team Member With Its Team In Gridview Using ASP.NET

clock October 6, 2016 21:38 by author Peter

In this post, i will tell you about Showing Team Member With Its Team In Gridview Using ASP.NET. This following code snippet is for to show team member with its team in Gridview using ASP.NET:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="GridView1_RowDataBound" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px" CellPadding="4"> 
    <FooterStyle BackColor="#FFFFCC" ForeColor="#330099" /> 
    <HeaderStyle BackColor="#990000" Font-Bold="true" ForeColor="#FFFFCC" /> 
    <AlternatingRowStyle BackColor="#DFDFD0" /> 
    <Columns> 
        <asp:BoundField DataField="Teamname" HeaderText="Teamname" /> 
        <asp:TemplateField HeaderText="Agentname"> 
            <ItemTemplate> 
                <asp:DropDownList ID="ddlagent" runat="server" Width="250px" /> </ItemTemplate> 
        </asp:TemplateField> 
        <asp:TemplateField HeaderText="CountAgent"> 
            <ItemTemplate> 
                <asp:Label ID="lblAgent" runat="server" Width="100px" /> </ItemTemplate> 
        </asp:TemplateField> 
    </Columns> 
    <PagerStyle BackColor="#FFFFCC" ForeColor="#330099" HorizontalAlign="Center" /> 
    <RowStyle BackColor="White" ForeColor="#330099" /> 
    <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="#663399" /> 
    <SortedAscendingCellStyle BackColor="#FEFCEB" /> 
    <SortedAscendingHeaderStyle BackColor="#AF0101" /> 
    <SortedDescendingCellStyle BackColor="#F6F0C0" /> 
    <SortedDescendingHeaderStyle BackColor="#7E0000" />  
</asp:GridView> 

Code

using System.Data; 
using System.Data.SqlClient; 
using System.Configuration; 
public partial class Default2: System.Web.UI.Page { 
    string ConnStr = ConfigurationManager.ConnectionStrings["CRMConnectionString"].ToString(); 
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["CRMConnectionString"].ToString()); 
    DataSet someDataSet = new DataSet(); 
    SqlDataAdapter adapt = new SqlDataAdapter(); 
    protected void Page_Load(object sender, EventArgs e) { 
        TopTeam(); 
    } 
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e) { 
        if (e.Row.RowType == DataControlRowType.DataRow) { 
            con.Open(); 
            var ddl = (DropDownList) e.Row.FindControl("ddlagent"); 
            var Agent = (Label) e.Row.FindControl("lblAgent"); 
            string TeamName = e.Row.Cells[0].Text.ToString(); 
            SqlCommand cmd = new SqlCommand("SELECT distinct (Agentname +' , ' + Hr_id) as [Agentname] FROM CRM_Agentname " + " WHERE TeamName = '" + TeamName + "' and status='Active'", con); 
            SqlDataAdapter da = new SqlDataAdapter(cmd); 
            DataSet ds = new DataSet(); 
            da.Fill(ds); 
            con.Close(); 
            ddl.DataSource = ds; 
            ddl.DataTextField = "Agentname"; 
            ddl.DataValueField = "Agentname"; 
            ddl.DataBind(); 
            int totalItems = ddl.Items.Count; 
            Agent.Text = totalItems.ToString(); 
        } 
    } 
    private void TopTeam() { 
        con.Open(); 
        SqlCommand cmd = new SqlCommand("SELECT DISTINCT TeamName FROM CRM_Teamname where status='ACtive' and process like 'r%' and teamname!='---- Select ----'", con); 
        SqlDataAdapter da = new SqlDataAdapter(cmd); 
        DataSet ds = new DataSet(); 
        da.Fill(ds); 
        con.Close(); 
        GridView1.DataSource = ds; 
        GridView1.DataBind(); 
        con.Close(); 
    } 
}

HostForLIFE.eu ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



European ASP.NET Core Hosting - HostForLIFE.eu :: How to Fix Error 502.5 - Process Failure in ASP.NET Core

clock October 4, 2016 19:35 by author Scott

This is an issue that sometimes you face when you deploying your ASP.NET Core on shared hosting environment.

Problem

HTTP Error 502.5 - Process Failure

Common causes of this issue:

* The application process failed to start
* The application process started but then stopped
* The application process started but failed to listen on the configured port

Although your hosting provider have setup .net core for you, you can face error above. So, how to fix this problems?

Solution

There are 2 issues that cause the above error

#1. Difference ASP.NET Core Version

1. The difference ASP.NET Core version. Microsoft just released newest ASP.NET Core 1.0.1. Maybe you are still using ASP.NET Core 1.0. So, you must upgrade your .net Core version.

2. When you upgraded your app, make sure that your ‘Microsoft.NETCoreApp’ setting in your project.json was changed to:

"Microsoft.NETCore.App": "1.0.1",

3. Fixing your App ‘type’

"Microsoft.NETCore.App": { "version": "1.0.1", "type": "platform" },

#2. Set path to dotnet.exe in the web.config

Here is example to change your web.config file:

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <!--
    Configure your application settings in appsettings.json. Learn more at https://go.microsoft.com/fwlink/?LinkId=786380
  -->
  <system.webServer>
    <handlers>
      <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
    </handlers>
    <aspNetCore processPath="C:\Program Files\dotnet\dotnet.exe" arguments=".\CustomersApp.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" forwardWindowsAuthToken="false" />
  </system.webServer>
</configuration>

Conclusion

We hope above tutorial can help you to fix ASP.NET Core problem. This is only our experience to solve above error and hope that will help you. If you need ASP.NET Core hosting, you can visit our site at http://www.hostforlife.eu. We have supported the latest ASP.NET Core 1.0.1 hosting on our hosting environment and we can make sure that it is working fine.



ASP.NET Core 1.0 Hosting - HostForLIFE.eu :: How to Get DropDownList , Value, Index and Text in ASP.NET using JavaScript?

clock September 29, 2016 21:02 by author Peter

In this code snippet, we learn how to get selected value, selected index and selected of asp dropdownlist in JavaScript. First, Create new web application in visual studio.
Now, Add one webform to application. In this tutorial we added WebForm1 in application. And Then Add on DropDownList control to webform. Design webform as follows:

<%@ Page Language="C#" AutoEventWireup="true"CodeBehind="WebForm1.aspx.cs" Inherits="DropDownListJS.WebForm1" %> 
<!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></title> 
<script type="text/javascript"> 
function GetListDetails() { 
    var param = document.getElementById('ddlColors'); 
    document.getElementById('lblText').innerHTML = param.options[param.selectedIndex].text; 
    document.getElementById('lblValue').innerHTML = param.options[param.selectedIndex].value; 
    document.getElementById('lblIndex').innerHTML = param.options[param.selectedIndex].index; 

</script> 
</head> 
<body> 
<form id="form1" runat="server"> 
<div> 
    <table> 
        <tr> 
            <td> 
                Colors 
            </td> 
            <td> 
                <asp:DropDownList ID="ddlColors" runat="server" onchange="GetListDetails()"> 
                    <asp:ListItem Text="Select" Value="0" /> 
                    <asp:ListItem Text="Red" Value="11" /> 
                    <asp:ListItem Text="Green" Value="22" /> 
                    <asp:ListItem Text="Blue" Value="33" /> 
                </asp:DropDownList> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Selecte Index :
            </td> 
            <td> 
                <label id="lblIndex">
                </label> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Selecte Text : 
            </td> 
            <td> 
                <label id="lblText"> 
                </label> 
            </td> 
        </tr> 
        <tr> 
            <td> 
                Selecte Value : 
            </td> 
           <td> 
                <label id="lblValue"> 
                </label> 
            </td> 
        </tr> 
    </table> 
</div>
</form> 
</body> 
</html> 


Next step, Run application.

Finally, Change the color.

HostForLIFE.eu ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



European Entity Framework Core 1.0 Hosting - HostForLIFE.eu :: Speed Up Large Data Sets with .AsNoTracking

clock September 29, 2016 20:04 by author Scott

If you are experiencing performance issues with Entity Framework Core 1.0 when you try to include related objects in your LINQ and lambda expressions on record sets of just a few thousand records, then check out these examples on how to improve it. Of the many ways, the best way that I have found to negate those performance problems and to optimize your requests is by using .AsNoTracking()

What is AsNoTracking()
When you use .AsNoTracking() you are basically telling the context not to track the retrieved information. Sure, this turns off a useful EF feature, but in many cases (like building an api in my case) this feature is unneeded.

In summary, Tracking is turned on by default and is great if you want to retrieve and save objects all within the same context. But if this is not required, you should use AsNewTracking(). AsNoTracking() decouples the returned records from the context, making your queries much faster!

Example

IList<Player> playerList = db.Player.AsNoTracking().ToList()

Example with Joins

IList<Player> playerList = (from p in db.Player
                        select p)
                        .Include(p => p.Team)
                        .ThenInclude(t => t.League)
                        .AsNoTracking()
                        .ToList();

It is also worth noting that there is another way to decouple your objects from EF.  This other way can be done by adding .AsEnumerable().  That would look like this:

var decoupledList = from x in TableA<strong>.AsEnumerable()</strong>

 



ASP.NET Core 1.0 Hosting - HostForLIFE.eu :: How to Handling JSON Arrays Returned From ASP.NET Web Services With jQuery?

clock September 20, 2016 20:35 by author Peter

In this post, I will tell you about how to handling JSON Arrays returned from ASP.NET Web Services with jQuery.  JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

using System; 
using System.Collections.Generic; 
using System.Configuration; 
using System.Data; 
using System.Linq; 
using System.Text; 
using System.Text.RegularExpressions; 
using System.Web; 
using System.Web.Script.Serialization; 
using System.Web.Script.Services; 
using System.Web.Services; 
namespace VIS { 
[WebService(Namespace = "http://tempuri.org/")] 
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] 
[System.ComponentModel.ToolboxItem(false)] 
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
[System.Web.Script.Services.ScriptService] 
public class WebMyService: System.Web.Services.WebService { 
    string connetionString = null; 
    SqlConnection sqlCnn; 
    SqlCommand sqlCmd; 
    SqlDataAdapter adapter = new SqlDataAdapter(); 
    DataSet dsbind = new DataSet(); 
    int i = 0; 
    string sql = null; 
    public class Gender { 
        public string employeeid { 
            get; 
            set; 
        } 
        public string male { 
            get; 
            set; 
        } 
        public string female { 
            get; 
            set; 
        } 
    } 
    public string JSONConversion(DataTable dt) { 
            DataSet ds = new DataSet(); 
            ds.Merge(dt); 
            StringBuilder JsonString = new StringBuilder(); 
            JsonString.Append("{"); 
            JsonString.Append("\"Data\""); 
            JsonString.Append(":"); 
            if (ds != null && ds.Tables[0].Rows.Count > 0) { 
                JsonString.Append("["); 
                for (int i = 0; i < ds.Tables[0].Rows.Count; i++) { 
                    JsonString.Append("{"); 
                    for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { 
                        if (j < ds.Tables[0].Columns.Count - 1) { 
                            JsonString.Append("\"" + ds.Tables[0].Columns[j].ColumnName.ToString() + "\":" + "\"" + ds.Tables[0].Rows[i][j].ToString() + "\","); 
                        } else if (j == ds.Tables[0].Columns.Count - 1) { 
                            JsonString.Append("\"" + ds.Tables[0].Columns[j].ColumnName.ToString() + "\":" + "\"" + ds.Tables[0].Rows[i][j].ToString() + "\""); 
                        } 
                    } 
                    if (i == ds.Tables[0].Rows.Count - 1) { 
                        JsonString.Append("}"); 
                    } else { 
                        JsonString.Append("},"); 
                    } 
                } 
                JsonString.Append("]"); 
                JsonString.Append("}"); 
                return JsonString.ToString(); 
            } else { 
                return null; 
            } 
        } 
        [WebMethod] 
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)] 
    public Gender[] GenderWise() { 
        connetionString = "Data Source=ServerName;Initial Catalog=DatabaseName;User ID=UserName;Password=Password"; 
        sql = "select distinct(empid) as employeeid, count(case when gender='M' then 1 end) as Male, count(case when gender='F' then 1 end) as Female from V_CountOnGender"; 
        sqlCnn = new SqlConnection(connetionString); 
        try { 
            sqlCnn.Open(); 
            sqlCmd = new SqlCommand(sql, sqlCnn); 
            adapter.SelectCommand = sqlCmd; 
            adapter.Fill(dsbind); 
            JavaScriptSerializer obj = new JavaScriptSerializer(); 
            string result = string.Empty; 
            Gender[] arrlst = new Gender[dsbind.Tables[0].Rows.Count]; 
            if (dsbind.Tables[0].Rows.Count > 0) { 
                for (int i = 0; i < dsbind.Tables[0].Rows.Count; i++) { 
                    Gender objgender = new Gender(); 
                    objgender.employeeid = dsbind.Tables[0].Rows[i]["employeeid"].ToString(); 
                    objgender.male = dsbind.Tables[0].Rows[i]["Male"].ToString(); 
                    objgender.female = dsbind.Tables[0].Rows[i]["Female"].ToString(); 
                    arrlst.SetValue(objgender, i); 
                } 
            } else { 
                result = "No Record Found"; 
            } 
        } catch (Exception ex) {} 
        return arrlst;; 
    } 


This will go into the < head > section of the page: 

script type = "text/javascript" 
src = "script/jquery-1.2.6.min.js" > < /script> < 
script type = "text/javascript" > 
$(document).ready(function() { 
    $.ajax({ 
        type: "POST", 
        contentType: "application/json; charset=utf-8", 
        dataType: "json", 
        url: "/WebMyVoterService.asmx/GenderWise", 
        processData: false, 
        success: OnSuccess, 
        failure: function(response) { 
            alert("Can't be able to bind graph"); 
        }, 
        error: function(response) { 
            alert("Can't be able to bind graph"); 
        } 
    }); 

    function OnSuccess(response) { 
        var dpmale = []; 
        var dpfemale = []; 
        for (var i = 0; i < response.d.length; i++) { 
            var obj = response.d[i]; 
            var datamale = { 
                y: parseInt(obj.male), 
                label: obj.employeeid, 
            }; 
            var datafemale = { 
                y: parseInt(obj.female), 
                label: obj.employeeid, 
            }; 
            dpmale.push(datamale); 
            dpfemale.push(datafemale); 
        } 
        var chart = new CanvasJS.Chart("chartContainerbar", { 
            animationEnabled: true, 
            axisX: { 
                interval: 1, 
                labelFontSize: 10, 
                lineThickness: 0, 
            }, 
            axisY2: { 
                valueFormatString: "0", 
                lineThickness: 0, 
                labelFontSize: 10, 
            }, 
            toolTip: { 
                shared: true 
            }, 
            legend: { 
                verticalAlign: "top", 
                horizontalAlign: "center", 
                fontSize: 10, 
            }, 
            data: [{ 
                type: "stackedBar", 
                showInLegend: true, 
                name: "Male", 
                axisYType: "secondary", 
                color: "#f8d347", 
                dataPoints: dpmale 
            }, { 
                type: "stackedBar", 
                showInLegend: true, 
                name: "Female", 
                axisYType: "secondary", 
                color: "#6ccac9", 
                dataPoints: dpfemale 
            }] 
        }); 
        chart.render(); 
    } 
}); < /script> 

HostForLIFE.eu ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



ASP.NET Core 1.0 Hosting - HostForLIFE.eu :: Command Event On Buttons > Click Event On Button

clock September 13, 2016 21:14 by author Peter

Using Command event over Click events give us better control over Coding as it provide proper manageable way to control events in a single module.

If we tend to had 5-6 button the rather than using 5-6 button click events we can use "Command" event. Multiple buttons will have same Command Event function but Multiple buttons cannot have same Click button event. each Click and Command Button are often related to a single button but always Click event will be fired firstly. "CommandName" property of each button must also be specified for each button.This property will decide
"what to do" in Command function this is common for multiple buttons.

Using Command event over Click events provide us better control over coding as it provide proper manageable way to control events in a single module.

Note:
"CommandName" property is important and required of buttons if we are using "Command" event. we can rename the Command Event function's name.

Follow this pattern,
    protected void Button_Command(object sender, CommandEventArgs e) 
    { 
        switch (e.CommandName) { 
            case "button1": 
                Response.Write("Click from 1"); 
                break; 
            case "button2": 
                Response.Write("Click from 2"); 
                break; 
            case "button3": 
                Response.Write("Click from 3"); 
                break; 
        } 
    }  


and in aspx file,
    <asp:Button ID="Button1" runat="server" Text="Button1" CommandName="button1" OnCommand="Button_Command" /> 
    <asp:Button ID="Button2" runat="server" Text="Button2" CommandName="button2" OnCommand="Button_Command" /> 
    <asp:Button ID="Button3" runat="server" Text="Button3" CommandName="button3" OnCommand="Button_Command" /> 
 

HostForLIFE.eu ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



ASP.NET Core 1.0 Hosting - HostForLIFE.eu :: How to Post Multiple JSON Objects to Ajax Method in C#?

clock September 8, 2016 20:57 by author Peter

Today, I will show you How to Post Multiple JSON Objects to Ajax Method in C#.

C# web method
[System.Web.Services.WebMethod] 
public static void Post(object data, object dt) 

    List < Category > lstItems = new JavaScriptSerializer().ConvertToType < List < Category >> (data); 
    List < Product > lstprditems = new JavaScriptSerializer().ConvertToType < List < Product >> (dt); 
    string ctid = ""; 
    string ctnme = ""; 
    string pdid = ""; 
    string pdnme = ""; 
    for (int i = 0; i < lstItems.Count; i++) 
    { 
        ctid = ctid + "," + lstItems[i].categoryID; 
        ctnme = ctnme + "," + lstItems[i].categoryName; 
    } 
    for (int i = 0; i < lstprditems.Count; i++) 
    { 
        pdid = pdid + "," + lstprditems[i].productID; 
        pdnme = pdnme + "," + lstprditems[i].productName; 
    } 
    if (ctid.Length > 0) 
    { 
        ctid = ctid.Remove(0, 1); 
        ctnme = ctnme.Remove(0, 1); 
    } 
    if (ctid.Length > 0) 
    { 
        pdid = pdid.Remove(0, 1); 
        pdnme = pdnme.Remove(0, 1); 
    } 


Code
<html xmlns="http://www.w3.org/1999/xhtml"> 
 
<head runat="server"> 
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.2/jquery.min.js"></script> 
 
    <script type="text/javascript"> 
        function PassJavascriptObject() 
        { 
            var Ct = []; 
            var Pd = []; 
            var categoryModel = { 
                categoryID: 1, 
                categoryName: "Beverage" 
            }; 
            Ct.push(categoryModel); 
            var categoryModel1 = { 
                categoryID: 2, 
                categoryName: "Liuwu" 
            }; 
            Ct.push(categoryModel1); 
            var productModel = { 
                productID: 1, 
                productName: "Chai" 
            }; 
            Pd.push(productModel) 
            var productModel2 = { 
                productID: 2, 
                productName: "teccc" 
            }; 
            Pd.push(productModel2) 
            $.ajax( 
            { 
                url: 'WebForm1.aspx/Post', 
                type: 'post', 
                dataType: 'json', 
                // It is important to set the content type 
                // request header to application/json because 
                // that's how the client will send the request 
                contentType: 'application/json', 
                data: JSON.stringify( 
                { 
                    data: Ct, 
                    dt: Pd 
                }), 
                cache: false, 
                success: function(result) 
                { 
                    alert(result); 
                }, 
                error: function(xhr, ajaxOptions, thrownError) 
                { 
                    alert(thrownError); 
                } 
            }); 
        } 
    </script> 
 
</head> 
 
<body> 
    <form id="form1" runat="server"> 
        <div> 
            <span onclick="javascript:PassJavascriptObject();">Call Method</span> 
        </div> 
    </form> 
</body> 
 
</html>

HostForLIFE.eu ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



ASP.NET Core 1.0 Hosting - HostForLIFE.eu :: How to Authorized.Net And PayPal Express Gateway?

clock September 1, 2016 23:27 by author Peter

In this tutorial, I will show you how to Authorized.Net and PayPal Express Gateway. Now write the following code:

Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> 
 
<!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></title> 
</head> 
<body> 
    <form id="form1" runat="server"> 
    <div align="center"> 
      <table style="border: 1px solid black; vertical-align: middle;" id="table3">       
        <tr><td colspan="2" align="center"> 
            <asp:ValidationSummary ID="ValidationSummary1" ShowSummary="false" ShowMessageBox="true" ValidationGroup="fldGrp1" runat="server" /> 
        </td></tr> 
        <tr> 
            <td align="right"> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" ControlToValidate="ddlPaymentMethod" InitialValue="SELECT" ValidationGroup="fldGrp1" runat="server" ErrorMessage="Method is required"> * </asp:RequiredFieldValidator>Method:</td> 
            <td align="left"><asp:DropDownList ID="ddlPaymentMethod" onselectedindexchanged="ddlPyamentMethod_SelectedIndexChanged" AutoPostBack="true" runat="server"> 
                <asp:ListItem>SELECT</asp:ListItem> 
                <asp:ListItem>American Express</asp:ListItem> 
                <asp:ListItem>Discover</asp:ListItem> 
                <asp:ListItem>Master</asp:ListItem> 
                <asp:ListItem>Visa</asp:ListItem> 
                <asp:ListItem>Paypal</asp:ListItem> 
            </asp:DropDownList></td> 
        </tr> 
        <tr> 
            <td align="right"> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" ControlToValidate="txtNameOnCard" ValidationGroup="fldGrp1" runat="server" ErrorMessage="Name on card is required"> * </asp:RequiredFieldValidator>Name of the card:</td> 
            <td align="left"><asp:TextBox ID="txtNameOnCard" Width="250px" runat="server"></asp:TextBox></td> 
        </tr> 
        <tr> 
            <td align="right"> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator3" ControlToValidate="txtCreditCardNumber" ValidationGroup="fldGrp1" runat="server" ErrorMessage="Credit card number is required"> * </asp:RequiredFieldValidator>Credit card number:</td> 
            <td align="left"><asp:TextBox ID="txtCreditCardNumber" Width="250px" MaxLength="20" runat="server"></asp:TextBox></td> 
        </tr> 
        <tr> 
            <td align="right"><asp:RequiredFieldValidator ID="RequiredFieldValidator4" ControlToValidate="ddlExpMonth" InitialValue="0" ValidationGroup="fldGrp1" runat="server" ErrorMessage="Expiration month is required"> * </asp:RequiredFieldValidator>Expiration month:</td> 
            <td align="left"> 
                <asp:DropDownList ID="ddlExpMonth" runat="server"> 
                    <asp:ListItem Value="0">SELECT</asp:ListItem> 
                    <asp:ListItem Value="1">January</asp:ListItem> 
                    <asp:ListItem Value="2">February</asp:ListItem> 
                    <asp:ListItem Value="3">March</asp:ListItem> 
                    <asp:ListItem Value="4">April</asp:ListItem> 
                    <asp:ListItem Value="5">May</asp:ListItem> 
                    <asp:ListItem Value="6">June</asp:ListItem> 
                    <asp:ListItem Value="7">July</asp:ListItem> 
                    <asp:ListItem Value="8">August</asp:ListItem> 
                    <asp:ListItem Value="9">September</asp:ListItem> 
                    <asp:ListItem Value="10">October</asp:ListItem> 
                    <asp:ListItem Value="11">November</asp:ListItem> 
                    <asp:ListItem Value="12">December</asp:ListItem> 
                </asp:DropDownList> /<asp:RequiredFieldValidator ID="RequiredFieldValidator5" ControlToValidate="ddlExpYear" InitialValue="0" ValidationGroup="fldGrp1" runat="server" ErrorMessage="Expiration year is required"> * </asp:RequiredFieldValidator> 
                <asp:DropDownList ID="ddlExpYear" runat="server"></asp:DropDownList> 
            </td> 
        </tr> 
        <tr> 
            <td align="right"> 
                <asp:RequiredFieldValidator ID="RequiredFieldValidator6" ControlToValidate="txtSecurityCode" ValidationGroup="fldGrp1" runat="server" ErrorMessage="Security code is required"> * </asp:RequiredFieldValidator>Security Code:</td> 
            <td align="left"><asp:TextBox ID="txtSecurityCode" Width="60px" MaxLength="5" runat="server"></asp:TextBox></td> 
        </tr> 
        <tr><td colspan="2" align="center"><asp:Label ID="lblGatewayMessage" Font-Bold="true" runat="server"></asp:Label></td></tr> 
        <tr><td colspan="2" align="center"> 
                 <asp:Button ID="btnChargeCard" Text="Pay-Now" OnClick="AuthorizedDotNet_Collect" ValidationGroup="fldGrp1" runat="server" />                  
        </td></tr> 
        <tr><td colspan="2" align="center"> </td></tr> 
      </table> 
    </div> 
    </form> 
</body> 
</html> 

Default.aspx.cs

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
using ncMerchantGateway; 
 
public partial class _Default : System.Web.UI.Page 

    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!Page.IsPostBack) 
        { 
            //- Let's do 10 years of credit card expiration year. 
            this.ddlExpYear.Items.Clear(); 
            this.ddlExpYear.Items.Add(new ListItem("SELECT", "0")); 
            for (int i = 0; i <= 10; i++) 
            { 
                if (i > 0) 
                { 
                    this.ddlExpYear.Items.Add(new ListItem(DateTime.Now.AddYears(i).Year.ToString(), i.ToString())); 
                } 
            } 
        } 
    } 
    protected void ddlPyamentMethod_SelectedIndexChanged(object sender, EventArgs e) 
    { 
        if (ddlPaymentMethod.Text.Trim().ToUpper() == "PAYPAL") 
        {    
            PayPalExpress_Collect(sender, e); 
        }         
    }     
    //--------------------------------------------------------------------------------- 
    //- Warning: a merchant account from authorized.net is required. 
    //--------------------------------------------------------------------------------- 
    protected void AuthorizedDotNet_Collect(object sender, EventArgs e) 
    {    
        //- Entantiate the class here 
        oAuthorizedotnet oGateway = new oAuthorizedotnet(); 
 
        //- very important information must be entered here 
        oGateway.MerchantAccount_Version = "3.1"; // Authorized.net api version. 
        oGateway.AccountHolder_LoginId = "valid login id goes here"; 
        oGateway.AccountHolder_TransactionKey = "valid merchant transaction key goes here"; 
        oGateway.AccountHolder_EMail = "merchart email registered with authorized.net goes here"; 
        oGateway.CompanyCollectorName = "ABC, Inc."; //- Merchant Company name goes here 
        oGateway.AuthorizeChargesOnly = true; // Authorized Only (False = {Authorized and Capture}) 
        oGateway.Country = "USA"; 
        oGateway.Currency = "USD"; 
        oGateway.IsTestMode_Environment = false; //- Live  
 
        //- Amount to be charged 
        double dblCharges = 50.00; 
        //- Sales Tax if there is any based on NYC sales tax. 
        double dblSalesTax = (50.00 * 0.09); 
        //- Total to Collect 
        double dblTotalCharges = dblCharges + dblSalesTax; 
 
        List<string> lstCCPaymentData = new List<string>(); 
        //- Please follow this order 0 throught 12 
        lstCCPaymentData.Add("Jane"); //-Billing First-Name 
        lstCCPaymentData.Add("Doe"); //-Billing Last-Name 
        lstCCPaymentData.Add("123 Apple Road"); //-Billing Address 
        lstCCPaymentData.Add("New York"); //-Billing City 
        lstCCPaymentData.Add("NY"); //-Billing State 
        lstCCPaymentData.Add("10040"); //-Billing Zipcode 
        lstCCPaymentData.Add("212-555-5555"); //-Billing Telephone 
        lstCCPaymentData.Add("[email protected]"); //-shipping email //-7 
         
        //- Credit card info. exactly in this order. 
        lstCCPaymentData.Add(this.txtCreditCardNumber.Text); //-Credit Card number 
        lstCCPaymentData.Add(this.ddlExpMonth.Text); //- Credit card expiration month 
        lstCCPaymentData.Add(this.ddlExpYear.Text); //-Credit card expiration year 
        lstCCPaymentData.Add(this.txtSecurityCode.Text); //-Credit card security code 
        lstCCPaymentData.Add(dblTotalCharges.ToString()); //-Total Amount to be either authorized or capture 
 
        //- Connect with Authorize.net gateway now. 
        oGateway.AuthorizeCaptureCharges(lstCCPaymentData); 
 
        //- Return Message.(Display any error message returned from the Authorized.net gateway here) 
        this.lblGatewayMessage.Text = oGateway.GatewayReturnedMessage.Trim(); 
    } 
    //--------------------------------------------------------------------------------- 
    //- Warning: you must have a paypal account with valid email registered. 
    //--------------------------------------------------------------------------------- 
    protected void PayPalExpress_Collect(object sender, EventArgs e) 
    { 
         
        //- Entantiate the class here 
        oPayPalExpress oGateway = new oPayPalExpress(); 
 
        //- very important information must be entered here 
        oGateway.ECommerce_SiteEMail = "[email protected]"; 
        oGateway.ECommerce_SiteUrl = "www.johndoe.com"; 
        oGateway.Country_Code = "US"; 
        oGateway.Currency_Code = "USD"; 
        oGateway.CancelledTransaction_Url = "http://www.johndoe.com/CancelledTransaction.html"; 
        oGateway.ReturnToECommerce_SiteUrl = "http://www.johndoe.com/Thankyou.html"; 
 
        //- Amount to be charged 
        double dblCharges = 50.00; 
        //- Pay Pal Fee if there is any [Warning: you must let the user know about this fee charges.] 
        double dblProcessingFee = (dblCharges * 2.75) / 100;        
        //- Sales Tax if there is any based on NYC sales tax. 
        double dblSalesTax = (50.00 * 0.09); 
        //- Total to Collect 
        double dblTotalCharges = dblCharges + dblSalesTax + dblProcessingFee; 
         
        List<string> lstPaymentInfo = new List<string>(); 
        //- Please follow this order 
        lstPaymentInfo.Add("10012A"); //- Item Number 
        lstPaymentInfo.Add("Tennis Shoes Size 10"); //- Item Description 
        lstPaymentInfo.Add("1"); //- Qty goes here at least 1 
        lstPaymentInfo.Add(dblTotalCharges.ToString()); //- Amount to charge goes here 
        lstPaymentInfo.Add("20160813104523"); //- Invoice Number goes here 
        lstPaymentInfo.Add(""); //- Shipping charges if any goes here otherwise blank 
        lstPaymentInfo.Add(""); //- Handling charges if any goes here otherwise blank 
        lstPaymentInfo.Add(dblSalesTax.ToString()); //- Sales Taxes if any goes here otherwise blank  
         
        //- This part from here down is not necessary could all be blank "" 
        lstPaymentInfo.Add("Jane"); //- First-name 
        lstPaymentInfo.Add("Doe"); //- Last-name 
        lstPaymentInfo.Add("123 Somewhere in the city"); //- Address 
        lstPaymentInfo.Add("New York"); //- City 
        lstPaymentInfo.Add("NY"); //- State 
        lstPaymentInfo.Add("10005"); //- Zipcode 
        lstPaymentInfo.Add("212-555-5555"); //- Telephone 
        lstPaymentInfo.Add("[email protected]"); //- E-Mail 
         
        //- Go to paypal now and collect 
        oGateway.ProcessPayment(lstPaymentInfo);         
    } 

 

HostForLIFE.eu ASP.NET Core 1.0 Hosting

European best, cheap and reliable ASP.NET hosting with instant activation. HostForLIFE.eu is #1 Recommended Windows and ASP.NET hosting in European Continent. With 99.99% Uptime Guaranteed of Relibility, Stability and Performace. HostForLIFE.eu security team is constantly monitoring the entire network for unusual behaviour. We deliver hosting solution including Shared hosting, Cloud hosting, Reseller hosting, Dedicated Servers, and IT as Service for companies of all size.



About HostForLIFE

HostForLIFE is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes.

We have offered the latest Windows 2019 Hosting, ASP.NET 5 Hosting, ASP.NET MVC 6 Hosting and SQL 2019 Hosting.


Month List

Tag cloud

Sign in