Monday, February 25, 2008

Scott Guthrie






Scott Guthrie is a vice president in the Microsoft Developer Division. He runs the development teams that build ASP.NET, Common Language Runtime (CLR), Windows Presentation Foundation (WPF), Silverlight, Windows Forms, Internet Information Services 7.0, Commerce Server, .NET Compact Framework, Visual Web Developer and Visual Studio Tools for WPF. He is best known for his work on ASP.NET, which he and colleague Mark Anders developed while at Microsoft.[1]

SqlServer Database Connection in asp.net with C#

Microsoft SQL Server is a relational database management system (RDBMS) produced by Microsoft. Its primary query language is Transact-SQL, an implementation of the ANSI/ISO standard Structured Query Language (SQL) used by both Microsoft and Sybase.


Add SQL Connection in asp.net with c#:






How to get Connection String for SQLConnection :










Source Code :


using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;

public partial class data : System.Web.UI.Page
{
SqlConnection scn = new SqlConnection("Data Source=.;Initial Catalog=master;Integrated Security=True");

protected void Page_Load(object sender, EventArgs e)
{

}
}

Serial Communication with MSComm Control in windows application

Add Reference for Serial Communication:



Add MSComm Control For Serial Communication:




Serial Communication Form Design:





Source Code For Serial Communication:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Globalization;
using System.IO;
using System.Diagnostics;
using System.Threading;

namespace mifaretest
{
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private static int num;
private static string st;

private void button1_Click(object sender, EventArgs e)
{
num = Convert.ToInt32(txtamt.Text);

st = num.ToString("X");
int bt = st.Length;
for (int i = 0; i < 8 - bt; i++)
{
st = "0" + st;
}
axMSComm1.Output = "+" + "04" + st;
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
string b = axMSComm1.Input.ToString();
string u = b.Substring(0, b.IndexOf("\r\n"));

int c = Convert.ToInt32(u, 16);

txtbal.Text = c.ToString();
}

}



private void Form2_Load(object sender, EventArgs e)
{
if (axMSComm1.PortOpen == false)
{
axMSComm1.PortOpen = true;
}


}

private void btnwithdrawal_Click(object sender, EventArgs e)
{
num = Convert.ToInt32(txtamt.Text);

st = num.ToString("X");
int bt = st.Length;
for ( int i = 0; i < 8 - bt; i++)
{
st = "0" + st;
}
axMSComm1.Output = "-" +"04" + st;
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
string b = axMSComm1.Input.ToString();
string u = b.Substring(0, b.IndexOf("\r\n"));

int c = Convert.ToInt32(u, 16);

txtbal.Text = c.ToString();
}

}


private static int i=0;
private static string x;
private static string c;
private static string p;
private static string s;
private static string l;
private static string r;
private static string t;
private static string v;
private static string u;
private static int k;
private void button2_Click(object sender, EventArgs e)
{
axMSComm1.Output = "x";
int o = axMSComm1.InBufferCount;

Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
x = axMSComm1.Input.ToString();
}

axMSComm1.Output = "c";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
c = axMSComm1.Input.ToString();
}
axMSComm1.Output = " ";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
p = axMSComm1.Input.ToString();
}
axMSComm1.Output = "s";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
s = axMSComm1.Input.ToString();
}
axMSComm1.Output = "l" + "01" + "FF" + "\r\n";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
l = axMSComm1.Input.ToString();
}
axMSComm1.Output = "r" + "04";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
r = axMSComm1.Input.ToString();
}
axMSComm1.Output = "r" + "04";
Thread.Sleep(500);
if (axMSComm1.InBufferCount > 0)
{
t = axMSComm1.Input.ToString();
}
Thread.Sleep(500);

axMSComm1.Output = "rv" + "04";
Thread.Sleep(500);
// string m = x + c + p + s + l + r + t;
if (axMSComm1.InBufferCount > 0)
{
v = axMSComm1.Input.ToString();

u = v.Substring(0, v.IndexOf("\r\n"));
k = Convert.ToInt32(u, 16);
k = Int32.Parse(u, NumberStyles.HexNumber);

txtbal.Text = k.ToString();

}

}








}
}

Architecure of .NET FRAMEWORK

CLI
Assemblies
Metadata
Class library
Security
Memory management

.NET FRAMEWORK

The Microsoft .NET Framework is a software component that is a part of Microsoft Windows operating systems. It has a large library of pre-coded solutions to common program requirements, and manages the execution of programs written specifically for the framework. The .NET Framework is a key Microsoft offering, and is intended to be used by most new applications created for the Windows platform.

The pre-coded solutions that form the framework's Base Class Library cover a large range of programming needs in areas including: user interface, data access, database connectivity, cryptography, web application development, numeric algorithms, and network communications. The class library is used by programmers who combine it with their own code to produce applications.

Programs written for the .NET Framework execute in a software environment that manages the program's runtime requirements. This runtime environment, which is also a part of the .NET Framework, is known as the Common Language Runtime (CLR). The CLR provides the appearance of an application virtual machine, so that programmers need not consider the capabilities of the specific CPU that will execute the program. The CLR also provides other important services such as security mechanisms, memory management, and exception handling. The class library and the CLR together compose the .NET Framework.

The .NET Framework is included with Windows Server 2003, Windows Server 2008 and Windows Vista, and can be installed on most older versions of Windows

hello world program in asp.net with c#

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

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

}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("Hello World");
}
}

CodeRenderBlock in asp.net

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





Untitled Page




<% for (int i = 0; i <= 6; i++)
{ %>


Welcome to ASP.NET
<%} %>



Hello World Program in asp.net

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>





Untitled Page




Hello World






helloworldprogram in asp.net

Increasing Developer Productivity by Using Login Control





Increasing Developer Productivity by Using Login Control











Usage of Login Control reduces the time to create
a Login Control. This example depicts how to increase the developer productivty.






x









stylesheet.cs:=
html, body {
background-color: #FFFFFF;
color: #000000;
font: normal 90%/1.8em 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif;
margin: 0;
height: 100%;
}
h1 {
font-size: 1.8em;
font-weight: bold;
margin-top: 0em;
margin-bottom: 0em;
color: #a83930;
}
h2 {
font-size: 1.6em;
margin: 1.0em 0em 1.0em 0em;
font-weight: bold;
color: #a83930;
}
h3 {
font-size: 1.2em;
margin: 1.0em 0em 1.0em 0em;
font-weight: bold;
color: #a83930;
}
p {
font-size: 1.1em;
line-height: 1.8em;
margin: 1.1em 0em 1.1em 0em;
text-align: left;
}
ul
{
font-size: 1.1em;
}
a:link, a:visited {
color: #cc3300;
text-decoration: underline;
}
a:hover {
text-decoration: none;
}
a:active {
color: #ff9900;
text-decoration: underline;
}
title {
color: #a83930;
}
#header {
height: 8px;
padding: 0 0px 0 0px;
color: #a83930;
background-color: #000000;
border-bottom: 8px solid #d30a1a;
}
#header h1 {
padding: 10px 0 0 0;
margin: 10px 0 0 0px;
color: #FFFFFF;
margin-left: 10px;
margin-bottom: 10px;
}
#logo {
background-color: #000000;
background: url(images/logo.gif);
background-position: top left;
background-repeat: no-repeat;
height: 100px;
width: 100px;
border: 0;
float: left;
}
#content {
margin-left: 210px;
padding: 0 20px 1.8em 10px;
background-color: #fff;
}
.code {
color: #a83930;
background-color: #fdea12;
font: 0.9em/1.4em verdana, arial, helvetica, sans-serif;
float: right;
border: solid 1px #a83930;
padding: 10px;
}

#sidebar {
float:left;
padding: 0 10px 10px 10px;
background-color: #656565;
/*background-image: url(images/bg_2.gif);*/
background-repeat: repeat-y;
background-position: top left;
border-top: 2px solid #656565;
border-bottom: 2px solid #656565;
width: 168px; /* ds */
height:500px;
}
html>body #sidebar {
width: 180px;
}
#sidebar h3 {
font-weight: bold;
padding-bottom: 0.5em;
border-bottom: 1px dashed #fdea12;
color: #fdea12;
}

#nav a:link, #nav a:visited {
/*display: block;*/
width: 99.99%; /* for IE5 */
color: #FFFFFF;
text-decoration: none;
padding: 0.25em 0.5em 0.25em 0.5em;
font-weight: bold;
}
#nav a:hover {
text-decoration: none;
color: #FFFFFF;
/*background-color: #fdea12; */
}

.title {
color: #a83930;
font: bold 1.0em/1.0em verdana, arial, helvetica, sans-serif;
text-align: center;
padding-bottom: 5px;
border-bottom: #a83930 thin solid;
margin-bottom: 5px;
}
#footer {
/*margin-left: 210px; */
padding: 0 20px 1.8em 10px;
border-top: 1px solid #000000;
clear: both;
}
#footer p {
font: normal 0.8em/0.9em verdana, arial, helvetica, sans-serif;
color: #666;
}
#footer p.left {
float: left;
clear: left;
}
#footer p.right {
float: right;
clear: right;
}
.spacer {
clear: both;
}
dd, dt {
font-size: 0.95em;
}
#mainTitle {
font-size: 2.0em;
font-weight: bold;
visibility: hidden;
}
.pageTitle {
font-size: 1.5em;
font-weight: bold;
}
.itemTitle {
border-bottom: 1px solid #a83930;
font-size: 1.5em;
}
.itemContent {
padding-bottom: 1.8em;
}
.box {
border: solid 1px #a83930;
}
.boxFloat {
/* border: solid 1px #a83930; */
float: left;
}
.boxFloatRight {
border: solid 1px #a83930;
float: right;
}
.floatRight {
/* border: solid 1px #a83930; */
float: right;
}

.newsItem
{
padding-top: 1.0em;
border-bottom: 1px solid #a83930;
}
.newsTitle
{
font-size: 110%;
/*
float: left;
*/
}
.newsDate {
font: normal 0.9em/0.9em 'Lucida Grande', Verdana, Geneva, Lucida, Helvetica, Arial, sans-serif;
float: right;
/* clear: right; */
color: #666666;
}
.newsContent {
text-align: left;
}
.rowSelected {
background-color: #FEF268;
}

input.buttonLink
{
text-decoration: underline;
border: 0px;
background-color: Transparent;
}

.grid {
margin-bottom: 10px;
}
.grid TR TD {
padding: 1px 5px 1px 5px;
}

.details, .details TR, .details TD{
border-style: none;
border-width: 0;
padding-left: 20px;
}
.detailsHeader
{
background-color: #FEF268;
border: solid 1px green;
}

asp.net tutorials with framework

It is not essential to use the standard webforms development model when developing with ASP.NET. Noteworthy frameworks designed for the platform include:

Castle Monorail, an open-source MVC framework with an execution model similar to Ruby on Rails. The framework is commonly used with Castle ActiveRecord, an ORM layer built on NHibernate.
Spring.NET, a port of the Spring framework for Java.

[edit] History
Date Version Remarks New features
January 16, 2002 1.0 First version

released together with Visual Studio .NET
Object oriented web application development supporting Inheritance, Polymorphism and other standard OOP features
Developers are no longer forced to use Server.CreateObject(...), so early-binding and type safety are possible.
Based on Windows programming; the developer can make use of DLL class libraries and other features of the web server to build more robust applications that do more than simply rendering HTML ( i.e. exception handling )

April 24, 2003 1.1 released together with Windows Server 2003

released together with Visual Studio .NET 2003
Mobile controls
Automatic input validation

November 7, 2005 2.0 codename Whidbey
released together with Visual Studio 2005 and Visual Web Developer Express
and SQL Server 2005
New data controls (GridView, FormView, DetailsView)
New technique for declarative data access (SqlDataSource, ObjectDataSource, XmlDataSource controls)
Navigation controls
Master pages
Login controls
Themes
Skins
Web parts
Personalization services
Full pre-compilation
New localization technique
Support for 64-bit processors
Provider class model

November 19, 2007 3.5 released together with Visual Studio 2008
New data controls (ListView, DataPager)
Integrated AJAX support
Improved support for nested master pages
Support for LINQ

Using Authorization with Swagger in ASP.NET Core

 Create Solution like below LoginModel.cs using System.ComponentModel.DataAnnotations; namespace UsingAuthorizationWithSwagger.Models {     ...