Simple Example with .NET (.aspx & c#)

It is interesting to learn .NET technology especially aspx (ASP.NET 3.x) & C# based on JAVA background for about 10 yrs. To start with, simple example created, aspx file to show form & result on page & c# will process the form data.

Index.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="WebApplication2.Index" %>
<!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" />
<body>
<form id="form1" runat="server">
<div>
First Name : <asp:TextBox id="fname" runat="server" /> <br />
Last Name :  <asp:TextBox id="lname" runat="server" /> <br />
<asp:Button id="btnSubmit" runat="server" onclick="btnSubmit_Click"
Text="Submit" /> <br /><br />
<b></b><asp:Label id="result" runat="server" ForeColor="Blue" /> </b>
</div>
</form>
</body>
</html>

Index.aspx.cs

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace WebApplication2 {
public partial class Index : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
    }
    protected void btnSubmit_Click(object sender, EventArgs e) {
        result.Text = ("FNAME: " + fname.Text + "t LNAME: " + lname.Text);
         System.Console.WriteLine(result.Text);
    }
 }
}

It is interesting to learn .NET technology especially aspx (ASP.NET 3.x) & C# based on JAVA background for about 10 yrs. To start with, simple example created, aspx file to show form & result on page & c# will process the form data. Index.aspx <%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”index.aspx.cs” Inherits=”WebApplication2.Index” %> <!DOCTYPE html PUBLIC “-//W3C//DTD…

Leave a Reply

Your email address will not be published. Required fields are marked *