inherit theme : StyleSheetTheme="Theme1 : Debugging steps:

Get and set properties

  • Creating component using a class
  • Creating object of this class in the clients, using new key word
  • introducing the concept of Constructor
  • StyleSheetTheme="Theme1
  • Debugging steps: objects

Create New website

Create a CSS

Add a Theme and move main.css to Theme1 folder

Register "Theme1" in Default.aspx.

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

Edit main.css

body
{
background-color:#FFFFCC ;
color:#000080;
font-size:14px;
}
 

Confirm in the run time

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

<!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>mm.cont13 : creating and using component</title>
</head>
<body >
<form id="form1" runat="server">
<div>
This is default Home page..
</div>
</form>
</body>
</html>
 

Add a folder

Now add a class using Add New Item menu

Add a Namespace Generic

As you see, you get all help to map your application.

Add the follwoing codes in FirstCom.cs

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

/// <summary>
/// Summary description for FirstCom
/// </summary>
public class FirstCom
{
string str = ""; public string dstr = "";
static int n1 =0;
public FirstCom()
{
//
// TODO: Add constructor logic here

if (n1 == 0)  {  str += "Default Constructor Says: A new Object is created <br/>"; }
else {  str += "Default Constructor Says: You Visited this page " + (n1-1) + " Times <br/>"; }
}
public string MyMessage()
{
str += "Hi, there you are <br/>" + dstr;
n1++;  return str;
}
// overloading constructor
public FirstCom(string name)
{
this.dstr = "Parameter Constructor says Hello to "+ name;
//
}
public string _pMessage()
{
return dstr;
}
}


 

Once you crate that class and you can now create object from it

Now retrieve message from the class. use Default.aspx.cs to retrieve message from the method or function in FirstCom.cs

Add the following codes in Default.aspx

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

<!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>mm.cont13 : creating and using component</title>
</head>
<body >
<form id="form1" runat="server">
<div>
This is default Home page..<br />
<asp:Label ID="L1" runat="server" Text="<h1>Message Holder </h1><br />" />
</div>
</form>
</body>
</html>
 

Add these codes in Default.aspx.cs

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

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
FirstCom fc = new FirstCom();
L1.Text += fc.MyMessage();//.ToString();
FirstCom pc = new FirstCom("Manas");
L1.Text += pc._pMessage();
}
}
 

Runtime Analysis

Debugging steps:

 App_Web_wa-v-1cg.dll!_Default.Page_Load(object sender = {ASP.default_aspx}, System.EventArgs e = {System.EventArgs}) Line 17 C#


Now look at the client side first

Note object is formed, use F10 to move along with debug

Loads the Page for the first time

There is a parameter Visualizer, you may use to view how the parameter is being sent

Visual Studio has another important feature, that is a Class designer with many options for the developers.