PDA

View Full Version : ASP - ASP.net - the difference and common PHP factors


Taylor_1978
06-07-2005, 07:47 AM
Hiya,

I have taught myself over the years PHP, and consider myself advanced at it. I have been told in the past (possibly incorrectly) that ASP and PHP are quite similar.

I am wondering if this is correct, and also how extent the differences are between ASP and ASP.net.

Any information or thoughts would be greatly appreciated.

Thanks! :thumbsup:

miranda
06-07-2005, 08:32 PM
Classic asp uses scripting like PHP does. Instead of having it's own scripting language though it uses either VBScript(Visual Basic Script), JScript or PerlScript as it's server side language. Most examples you will find are in VBScript and that is by far the most commonly used of the 3. For connections to objects it uses com components (ActiveX) which must be first registered to the machine. VBScript only uses one variable type and that is variant. Like PHP you can implicitly declare a variable by just writing it and assigning a value to it without declaring it first.(However you can force declaration of variables before use by using Option Explicit {similar to VB 6 and older versions of VB}). Since VBScript is a watered down version of VB the learning curve for VB programmers is hardly existant, (basically they have to learn what they cannot use.)

ASP.Net uses the full version of the languages. An application written in .NET for the desktop can be modified slightly and used on the web. ASP.Net uses server controls as well as com components. ASP.Net languages include VB.Net (VB 7), C#, Java, JScript (Perl, COBOL, Python, Pascal plus some others are planned) as the server side language. Code and HTML are almost completely seperated, and in most instances they are. Which is a plus if you work in a team. One person can develop the page, and leave the coding to someone else. Microsoft has a free tool for ASP.NET Development called the Microsoft Web Matrix. Unlike pages developed with Visual Studio.Net all code is on the page in a seperate script block. Whereas when using Visual Studio.Net the code is in a seperate Code behind file. One of the nice things about using a seperate code behind file is that the code can be compiled into a .dll and installed on the machine thus keeping your code private.

Since you are already familiar with PHP learning classic asp would be similar in that you can intermingle the HTML and the code. Wheareas learning asp.Net using C# you would be more familiar with the syntax of the code.

Whichever you decide, it helps to know as many as possible.

fractalvibes
06-07-2005, 10:54 PM
Absolutely. You'll find that Classic ASP and PHP follow a very similar paradigm
and the structure of a typical page written in either very much alike. Just a little different terminology and objects for doing the same things. PHP is actually the more powerfull of the two, with native support for image manipulation, Mail, uploads to name a few. In ASP those things take a COM component (a dll on the server).

ASP.NET is much more like VB. Similar to VB 6 where you have a form that you place components on and a module behind that to run code when events happen.

fv

Grant Palin
06-07-2005, 11:36 PM
You can simulate a "codebehind" in Classic ASP and PHP in a way...Simply keep your functions in a seperate file, and include that file into each page that would need those functions. Not copy and paste, but each language has a method to dynamically insert one file into another.

So you can keep your functions and classes separate from your HTML, and just use basic program logic and function calls mixed in with the HTML.

miranda
06-08-2005, 12:32 AM
You can simulate a "codebehind" in Classic ASP and PHP in a way...Simply keep your functions in a seperate file, and include that file into each page that would need those functions. Not copy and paste, but each language has a method to dynamically insert one file into another.

So you can keep your functions and classes separate from your HTML, and just use basic program logic and function calls mixed in with the HTML.

Except when it comes to filling out a form you intermingle the code. For example a classic asp example would be
<input type="text" name="foobar" id="foo" value="<%=objRs("foobar")%>">
or
Response.Write("<input type=""text"" name=""foobar"" id=""foo"" value=""" & objRs("foobar")& """>")
In PHP it would be
<input type="text" name="foobar" id="foo"value="<?echo $row["foobar"];?>">
or
echo('<input type="text" name="foobar" id="foo"value="'. $row["foobar"].'">');

and in ASP.NET it would be
in the code behind file
'using a datareader and an array
foo.Text = DataReader.GetString(0)
or
'just using a datareader
foo.Text = DataReader("foobar").ToString()
in the html
<asp:TextBox id="foo" runat="server" />

As long as there is interminglng of code and html it cannot be considered codebehind even if you have parts of it in a different file.

Grant Palin
06-08-2005, 05:03 PM
Good thing you pointed that out, since I don't know ASP.Net. But my point was that, in a way, you can have a codebehind of sorts in Classic ASP or PHP. Simply by separating your major code into another file, that's all.

Taylor_1978
06-10-2005, 08:46 AM
Thank you!! This info has been very helpful!

quentin
06-10-2005, 03:05 PM
.NET is an oriented language you cannot compare with asp 3 or php
it is not a question of tags like this or like that

I am using .NET Since more than 3 years now and i never write a single tag line in visual mode

you can build your own framework ir is impossible with asp 3 or php
>NET is similar to JAVA .. and better