Professional Power: Visual Studio 2008 Professional :

Partial classes

Step: 1 Create a new web site, using File> new > Web Site

Step 2; choose ASP.NET  Web Site that will create three files

As the name suggests partial class, you may expect that many classes the same name in the code module with different contents,  and it works as a series of stacks comprises one class.

 

Code 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
{
public String str1 = "default";
protected void Page_Load(object sender, EventArgs e)
{
// this is blank method
}
public int demo()
{
return (1234);
}
}
public partial class P1
{
private String str1 = "This is a public variable "; private String str2 = "OK";

public string method1()
{
this.str1 += " This method1 from partial class <br/> " +str2 + "<br/>";
return (this.str1);
}
}
public partial class P1
{
public string method2()
{
this.str2 += "This method2 from partial class <br/> " + str2 + "<br/>";
return (this.str2);
}
}
public class Tester
{
public string test_method()
{
P1 tp1 = new P1();
string stradd = tp1.method1() ;
stradd += tp1.method2();
// string stradd = tp1.method1() + tp1.method2();
return (stradd);
}
}
 

Edit default.aspx, as show below. The signs "<%  ---  %>" will connect to the class and objects stored in the server.

Like any advanced compiler/applications , it uses too-tips "Intellensnse" showing available objects.

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>Create and use Partial Class </title>
<style type="text/css">
.div1
{
position: absolute;top: 100px; width: 400px; border: 1px solid #000080;
text-indent: 10px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
HTML : Below will be dispalyed from _Default.aspx.cs
<div>
<% _Default df1 = new _Default();
string df_str = "Returend from a method : ";
Response.Write(df_str + df1.demo());
Response.Write("<br/> used a public string : " + df1.str1 );
Tester t1 = new Tester();
Response.Write("<div class='div1'> You may plug some elements with style");
Response.Write("<br/> this is from partial classes ");
Response.Write("<br/>" + t1.test_method());
Response.Write("<div/>");

%>
</div>
</form>
</body>
</html>
 

You may like add or edit current web.config file , writing "<compilation debug="true"/> allows to debug all the pages . Further when you are degbugging and applications in a remote server, you may like to turn of the custom error, <customErrors mode="Off">

<?xml version="1.0"?>
<configuration>
<system.web>
<authentication mode="Forms">
<forms loginUrl="default.aspx" protection="All" timeout="60"/>
</authentication>
<authorization>
<allow users="*"/>
</authorization>
<compilation debug="true"/>
<customErrors mode="Off">
</system.web>
</configuration>

Debugging Pages in with Visual WEB Developer you will Build a page that

Incase you decide to run with debug, you may do so with your modified web.config where debug is set as

<compilation debug="true"/>