Styles of ASP.NET design

stovellp

Newcomer
Joined
Mar 25, 2004
Messages
10
Hey guys,

I have recently been working on an ASP.NET website. The site was partly done in PHP, but since I want to learn ASP.NET I decided to re-write it (I know re-writes are bad, but it's a personal, not-for-profit site). I plan to use the ASP.NET skills I acquire in this project in a larger commercial application in a couple of months.

However, I am finding that writing the code in ASP.NET is slower than doing it in PHP. I have a feeling this is through my own fault, and not a fault with the technology.

I think the problem lies in my coding habbits.

With PHP, I had created an 'include' folder, with a file called 'include.php'. In that PHP file was a list of functions that get used quite frequently, such as validating users, writing the title and menus, etc.

In ASP.NET, I created a C# source file just using a regular text editor. Inside the C# source file was a single class that inherited from System.Web.Page. Using a batch file, I called the C# compiler and created a DLL from the source and have it copied to my \Bin folder on the web server. This DLL serves as my 'include.php', and has all the same functions include.php used to have.

Then, I began work on my ASPX files. Every page is just an .aspx file - no .aspc or the rest of that stuff. The files all begin with this:
PHP:
<%@ Page Language="C#" Inherits="BHeard.Page" Debug="True" %>
Where BHeard.Page is the class in the DLL I had created.

Everything works fine. I can use all the Request and Response properties without hassle.

But it feels like I'm just doing ASP or PHP coding but with ASP.NET syntax. Heres an example file:
PHP:
<%@ Page Language="C#" Inherits="BHeard.Page" Debug="True" %> <% SecureInput(); %>
<%
    // Figure out which section this is for
    string ID = "";
    Stitch.Database.DBResult dbResult;
    Hashtable row;
    
    string ThisSection = "artscom";
    if (this.QueryString["section"] != null)
    {
        ID = this.QueryString["section"].ToString();   
        dbResult = databaseConnection.SelectQuery("SELECT * FROM tblSections WHERE ID=" + ID + ""); 
        row = dbResult.FetchArray();
        if (row != null)
	    {
	        dbResult.Close();
	        PrintHeader("B-Heard - " + row["SectionTitle"]);
	        ThisSection = row["SectionName"].ToString();
	    }
	    else
	    {
	        dbResult.Close();
	        PrintHeader("B-Heard");
	    }	    
    }
    else
    {
        PrintHeader("B-Heard");
    }
    

    Hashtable ht = new Hashtable();
    ht.Add(0, "");
    PrintLeftMenu(ht);
    PrintBeginContent(true);
    
    // Get the contento
    dbResult = databaseConnection.SelectQuery("SELECT * FROM tblSectionArticles WHERE Passed=1 AND SectionName='" + ThisSection + "' ORDER BY Date DESC");
    row = dbResult.FetchArray();
    while (row != null)
    {
        Response.Write(CreateWindow(Filter(row["Title"].ToString()), "#FFFFFF", "#C0C0C0"));
        Response.Write("<a href='/Users/Profile.aspx?user=" + row["AuthorUsername"].ToString() + "'>" + row["AuthorUsername"].ToString() + "</a><font class='Sub'> - " + row["Date"].ToString() + "</font><br />");
        if (row["Image"].ToString().Length >= 1)
        {
            Response.Write("<img src='./Images/" + row["Image"].ToString() + "' align='left' />");
        }
        Response.Write(Filter(row["Teaser"]));
        Response.Write("<br /><br /><a href='./comments.aspx?id=" + row["ID"] + "'>View Full Article</a>");
        Response.Write(CloseWindow());
        Response.Write("<br />");
        
        row = dbResult.FetchArray();
        
    }
    dbResult.Close();
%>



<%
    PrintEndContent();
    PrintRightMenu();
    PrintEnd();
%>

You'll notice I never use any <script runat... or <asp:... tags, just render tags.

My questions:
By coding the way I am, does it seem I am missing out on a great deal of the functionality ASP.NET has to offer?

I've never been a fan of WYSIWYG editors, and I do prefer to hand code everything. But would it be much better in this case if I was to use the WebMatrix or Visual Studio .NET editors (I have them both installed, just never use them)?

And lastly, if I made my projects using the ASP.NET WebMatrix or VS.NET editors, with code behind and the .aspc's and all that other crap, would my pages still work on all the current browsers? One reason I have liked coding the way I have been is that as all the output is created by me, and theres not a single ASP.NET web control used, is I can be sure it will look the same in all browsers. But do the web controls work in all the common browsers? Am I just being pedantic?

Thankyou very much in advance,

Paul Stovell

PS: Any links to tutorials (not the ones at www.asp.net) that might help me would be awesome.
 
Back
Top