PHP vs ASP.Net

To be honest all you need on a page is a single literal and blast a template out to it. Any changable content could be replaced within the template. This works quite effectivally trust me.

The only dam thing I hate about .NET it its stupid god dam editor VS2003 it has the most anoying feature every known got streight from Frontpage! It redesigns your design, make a XHML strict page in the VS2003 editor! no chance, apart from that which you can get round using an external program anyway .NET is very efficant but both languages have there place.

Thanks

Andy
 
kahlua001 said:
'Code Behind
Public titleimg As String

'Your datasource
..
dtrReader.Read
titleimg = dtrReader("titleimg")
dtrReader.Close


I don't think you are following, though maybe you are. Honestly, if this is doable I'd be quite pleased. (Yet to look at those exmaples you suggested michael).

The code behind would look something more like:

Code:
'Code Behind
Public titleimg As String
Public template as String

'Your datasource
..
dtrReader.Read
titleimg = dtrReader("titleimg")
template=dtrReader("template")
dtrReader.Close

How would you now insert title into the template at the relevant point and then ouput the completed template to the page?

Solutions I can think of are:

1. define your own replace terms e.g. [=myvar] which you can replace using
a the variable name in your code. Though for several variables this becomes several lines of code
2. More complicated - perhaps somehow use the compiler services to actually compile your template maybe..

Both of these fall well short of the simplicity of:

eval("$parsedtemplate='".$template."';");
print $parsedtemplate;

Any changable content could be replaced within the template.

Are you meaning using a simple replace for your defined replace points at per 1 above? Or do you have something else in mind?

:)
 
mark007 said:
Maverick.Net doesn't seem to have anything programming related.

Code:
<html>
<Head></head>
<body>
<div class="title"><img src="$titleimg" /></div>
<div class="content">Content goes here</div>
</body>
</html>

If however the site owner decides to move the title image to the bottom of the page he can just edit the template to:

Code:
<html>
<Head></head>
<body>
<div class="content">Content goes here</div>
<div class="title"><img src="$titleimg" /></div>
</body>
</html>

As the template is evaluated no matter where the variable appears it is parsed.

Ok, your problem is that your thinking like a PHP programmer, not an ASP.NET programmer. The way you do that in ASP.NET is:

Code:
<html>
<Head></head>
<body>
<div class="title"><asp:Image runat="server" id="titleImg" /></div>
<div class="content">Content goes here</div>
</body>
</html>

Then in your code behind you tell that asp:image control what image to load, that is if you wanted to do it dynamically anyway. You could simply set it by setting the ImageURL property of that asp:image control.

Now you can move that control all around that page, doesn't matter. But technically, you could do it other ways as well. Such as:

Code:
...
<div class="title"><asp:literal runat="server" id="titleImg" /></div>
...

or

Code:
...
<div class="title"><img runat="server" id="titleImg" /></div>
...

Many ways to do it... ASP.NET is basically by default templated in the method that you are using with PHP.
 
Well the difference here is that this template I am talking about is to be stored in a database rather than an aspx file. Even if it weren't there may be other scenarios where a similar template within template may occur. That is where the problem lies. Been finding it hard to put across exactly what I mean I guess.

Hmm, Consider a page where I have a literal control. The Contents of this literal control are filled from a database. All is ok so far. No suppose however that this information that comes from the database contains varaibles. For arguments sake I'll use title again. A very simple template for a title might be <b>Title Here</b>. Now if I also load from the db the value of the title into a string variable How would I:

a) Create the template that would contain the variable remembereing that this needs to be stored as text in the database, and
b)Evaluate the template so that the variable is replaced by the actual title
?

Also on a templating sort of note - the exmaples I've seen of inheriting from a custom base class that inherits Page on each page in the site although very useful for adding standard functions to the page doesn't seem that useful from a page layout point of view as you are back to making html out of strings and having to escape all the quotes...just a thought anyway..

:)
 
mark007 said:
Well the difference here is that this template I am talking about is to be stored in a database rather than an aspx file. Even if it weren't there may be other scenarios where a similar template within template may occur. That is where the problem lies. Been finding it hard to put across exactly what I mean I guess.

Hmm, Consider a page where I have a literal control. The Contents of this literal control are filled from a database. All is ok so far. No suppose however that this information that comes from the database contains varaibles. For arguments sake I'll use title again. A very simple template for a title might be <b>Title Here</b>. Now if I also load from the db the value of the title into a string variable How would I:

a) Create the template that would contain the variable remembereing that this needs to be stored as text in the database, and
b)Evaluate the template so that the variable is replaced by the actual title
?

Also on a templating sort of note - the exmaples I've seen of inheriting from a custom base class that inherits Page on each page in the site although very useful for adding standard functions to the page doesn't seem that useful from a page layout point of view as you are back to making html out of strings and having to escape all the quotes...just a thought anyway..

:)


I that case, I'd create a custom user control, build properties for the dynamic parts of it (that are filled from the database).

Out of curiosity, what benegits are you looking to achieve by having your templates stored in a DB?
 
The idea is that the whole site design can be changed from anywhere by simply logging into the site and changing the templates.

This is how this forum works for example.

:)
 
In my opinion it's better to simply create themes(templates) as files, rather than in a db. First reason, performance. It's faster to read a file local to the web server than fetch data across the network. Second, the same thing can be done... simply login, change the templates. Just because it's a file doesn't mean it's any less editable. Last, reliability. It's safer to assume (as dangerous as assumptions are in programming already) that you will be able to safely access a local file rather than a database. There are more points of failure between ASP.NET and the templates if they are stored in a DB. Of course, that's assuming the database isn't on the same server as the web server (and most often they are separate).

ASP.NET 2.0 will up the ante by offering built in support for master pages and theming. Go play with the beta, beta.asp.net, and see for yourself (if you haven't already). I'm in love with 2.0! :)
 
Well the db and web server are on the same server in this case. For files I would have to give people FTP access or I guess I could create some code to deal with file management for the files I wished to let people change. The idea really though is to separate functionality from style completely and although with code behind files this is mostly acheived I wouldn't want to let someone with no ASP.Net experience loose on a .aspx page.

I think some of the 2.0 features could be interesting though I don't have time to play with the beta at the moment.

I can of course create the effect I am after to some extent by using my own parsing - perhaps making all variables enclosed in [] etc. I have done something similar for a templated menu control I created. Seemed the only way to template it as much as I wanted to.

:)
 
In essence, the interface for editing a template whether it's a file or a record in the db would be identical. I do understand what you mean by letting someone loose on an aspx page, as an error there would throw an exception… whereas the PHP eval() would simply not output something (I believe, going from memory on this).

While the “war” between ASP.NET and PHP wages on for the Internet, it has already been won on my front. I now use ASP.NET exclusively. Since my switch from PHP to ASP.NET, my earnings have nearly tripled. And, while a completely personal benefit, the level of professionalism around the ASP.NET framework has “pushed” me to produce more professional code/products. Although, I do admit, the express products that are coming with ASP.NET 2.0 will “muddy the waters” a bit. But ASP.NET v2.0 is just so nice compared to v1.1, I can’t wait until it’s finally released.
 
Interesting comments.

I do like .Net but think PHP and .Net do both have their place. I work with both. Alot of people still and will continue to use linux web servers and while this is the case knowing both is the only option.

:)
 
Yup, but I haven't run into too many situations where I coulnd't talk the client into using ASP.NET. I suppose it's because once I dispell the myths that building and hosting a .Net web app is expensive, they change their minds.
 
Back
Top