Node Notes

SSH Notes

C# Starting My First Web App

  1. Start Menu:
  2. New Project or file new Porject:
  3. Template:
  4. Visual C#:
  5. Web:
  6. ASP.NET Web Application
  7. Name: MyFirstWebApp (no spaces)
  8. Click OK:

 

  1. ASP.NET Templates
  2. click on Empty:

 

  1. Add Folder and core references for:
  2. Check Web Forms:
  3. Click OK button:

 

  1. Solution Explorer
  2. right click on Project Name
  3. Click on Add:
  4. Click on Web Form
  5. Specify Name for Item
  6. type Default:
  7. Click on OK:
  8. It will create page Dafault.aspx:
0
0
0
s2smodern

C# Arithmetic Operators

= NOT equality, it's assignment

Math Operators: + - * /

Addition Assignment
total = total + 5;
total += 5;

Increment Operator: i++;
Decrement Operator: i--;

0
0
0
s2smodern

C# Data Type Conversion

Implicit conversions - smaller type to larger type
without data loss, "upcasting"

Explicit conversions - require developer intervention,
possibility of data loss, "downcasting", either in
the form of cast or using a helper method.

Casting numbers:
int myInteger = (int)myDouble;

Numbers to strings:
string myString = myInteger.ToString();

String to Numbers:
int myInteger = int.Parse(myString);

0
0
0
s2smodern

C# Data type

The object type is an alias for System.Object in .NET.

Data Types
string => alphanumeric (defaults to "")
int => 2 billion to -2 billion (defaults to 0)
double => fractional value (defaults to 0.0)
bool => true or false (defaults to false)



0
0
0
s2smodern

C# Comment

Comments:    //  Single line 

Comments:    /* Multiline */

0
0
0
s2smodern

C# MyFirstWebApp

  1. type What is your first name? (Double space space):
  2. in Toolbox double click on TextBox:
  3. use arrow key to go to end of TexBox:
  4. press enter key twice:

  1. type What is your last name?  (Double space space):
  2. in Toolbox double click on TextBox:
  3. use arrow key to go to end of TexBox:
  4. press enter key twice:

  1. in Toolbox double click to insert Botton:
  2. use arrow key to go to end of Botton:
  3. press enter key twice:

  1. in Toolbox double click to insert Label:

  1. Select first TextBox:
  2. goto Properties Box (lower right hand side):
  3. find (ID): Type, firstNameTextBox:
  4. hit Enter key:

  1. Select second TextBox:
  2. goto Properties Box (lower right hand side):
  3. find (ID): Type, lastNameTextBox:
  4. hit Entere key:

  1. Select Botton control:
  2. goto Properties box:
  3. find (ID): Type, OkButton:
  4. Under Appearance category:
  5. find Text: Type, Click Me:
  6. hit Enter key:

  1. Select Label conrol:
  2. Under Misc category:
  3. find (ID): Type, resultLabel
  4. Under Appearance category:
  5. find Text: in textbox delete Lablel to remove the text:
  6. hit Enter key:

  1. Double click, Click Me Botton:
  2. It will open a new file called: Default.aspx.cs
  3. Make sure curse in inside: protected void OkButton_Click(object sender, EventArgs e)
  4. inside the the curley braces type :
            {
                string firstName = firstNameTextBox.Text;
                string lastName = lastNameTextBox.Text;

                string result = "Hello " + firstName + " " + lastName;

                resultLabel.Text = result;
            }

  1. Save your work:
  2. Now Run your work:
  3. Click the Green Arrow

Default.aspx

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

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form2" runat="server">
        <div>
            What is your first name?&nbsp;
            <asp:TextBox ID="firstNameTextBox" runat="server"></asp:TextBox>
            <br />
            <br />
            What is your last name?&nbsp;
            <asp:TextBox ID="lastNameTextBox" runat="server"></asp:TextBox>
            <br />
            <br />
            <asp:Button ID="OkButton" runat="server" OnClick="OkButton_Click" Text="Click Me" />
            <br />
            <br />
            <asp:Label ID="resultLabel" runat="server"></asp:Label>
        </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;

namespace MyFirstWebApp
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void OkButton_Click(object sender, EventArgs e)
        {
            string firstName = firstNameTextBox.Text;
            string lastName = lastNameTextBox.Text;

            string result = "Hello " + firstName + " " + lastName;

            resultLabel.Text = result;
        }

    }
}

0
0
0
s2smodern

SSL Checker

Server Hostname:

(e.g. www.google.com)
Check SSL

| |

Copyright © 2017. All Rights Reserved.

SiteLock