Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

PHP to ASP.NET

Status
Not open for further replies.

oohoohoohooh

Programmer
Apr 30, 2005
55
GB
Hi, I've recently started taking an interest in asp.net as many companies (web developers) look for experience in asp.net when employing people in php. I read a couple tutorials but was not quite sure how different it is. I found c# to be most similar to php but noticed that asp does some weird stuff like sometimes you don't have to put the standard tags around the scripting to use it. I also noticed something about runat="server" within many of the tags and what exactly is that all about.

I'd appreciate if you could help where possible I have visual studio set up with my own iis server and ms sql server setup too. Thanks
 
The script that does not require special tags is not really script at all. It is strongly typed source code that is compiled once by the programmer during design time.
PHP and classic ASP are compiled on the fly each time the page is requested.
Unlike PHP and ASP, the .Net source code (*.vb and *.cs) does not have to be included in the web site folder to function, it is used only to build the application which makes a DLL file that does have to be in the website's bin folder. The *.ASPX are required and are like the HTML portion of the page.
This compiled DLL takes the place of all that script we use to type in PHP and ASP.
The directive (<%@ Page Language="vb" Inherits="WebApplication1.Webpage1" %>) at the top of the ASPX page tells IIS to look in the DLL for a class object named "WebApplication1.Webpage1" for any special instructions on rendering the webpage.


<input id=mybutton type=button value="Click Here" >
IIS delivers this text from WebApplication1.Webpage1 to client browser verbatim and does not look in the WebApplication1.Webpage1 class for instructions .


<input id=mybutton type=button runat=server value="Click Here">
Before IIS delivers this to the browser it looks in the WebApplication1.Webpage1 class for any special instructions needed to render this button.
For instance in the server side Page_Load event for WebPage1.aspx:
Sub Page_Load()
mybutton.Visible=True
mybutton.Text="Click Here Again"
End sub


<ASP:Button id=mybutton text="Click Here" runat=server />
This is similar to using runat=server in the input control above. Except when it is clicked the page post back and the mybutton click event in the DLL is fired on the server instead of the client handling the click event alone.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top