...

View Full Version : Can you mix ASP and .NET pages?



creativeedg10
04-22-2011, 02:51 PM
I am working on a mobile site that uses .aspx for the pages; however, I am transferring information from older .asp pages. These .asp pages are reading database connections, and I am not clear how to convert these into .aspx pages without running into config errors that are unclear to me in fixing.

Is it bad practice to mix .asp and .aspx pages in a site? If not, how can I learn to better understand the conversion differences from .asp database connections to .aspx? This is the only obstacle I have going on at the moment with this site, and I would love to find a solution soon as I've been stuck here for a while. I do want to follow best practice.

The site works, but I would like to be consistent with the .aspx set up in pages. I appreciate any help you may have to offer, thank you.

Mike_O
04-25-2011, 03:06 PM
Hey creativeedg10,

As Chris Rock once said: "You can drive a car with your feet, but it doesn't mean it's to be done."

I am pretty sure there are some workarounds out there, but ask yourself, do you really want to go that route?

I will tell you one thing. In my opinion (and I don't think anyone would disagree), the fact that you already know legacy ASP is definitely an advantage to you in terms of leaning .NET. Just go through some tutorials (plenty out there, just Google it)

Regards,
Mike

ghell
04-25-2011, 04:35 PM
Can you mix ASP and .NET pages?
Yes. You can have some pages as ASP and some as ASP.NET. You can't have both on the same page though, and any communication will be through mechanisms such as cookies.


Is it bad practice to mix .asp and .aspx pages in a site?
Yes. Convert all to ASP.NET.


how can I learn to better understand the conversion differences from .asp database connections to .aspx? This is the only obstacle I have going on at the moment with this site, and I would love to find a solution soon as I've been stuck here for a while. I do want to follow best practice.

The site works, but I would like to be consistent with the .aspx set up in pages. I appreciate any help you may have to offer, thank you.

http://www.w3schools.com/aspnet/aspnet_dbconnection.asp etc

In general you will be using Microsoft SQL Server for a DBMS with ASP.NET rather than OLE, so you would be using the System.Data.SqlClient (http://msdn.microsoft.com/en-us/library/system.data.sqlclient.aspx) namespace.

The typical differences are that ASP.NET provides mechanisms for data binding (http://www.w3schools.com/aspnet/aspnet_databinding.asp) (so you can say here is a grid to display data, and here is the data to fill it with, go fill it for me) and another common stumbling block is that you can only have a single result set open at a time, unless you use MARS (assume you don't when writing). This means you don't nest queries and result sets as you might in asp.

You can also define your connection string in web.config and not have to compile it into your source.

If you don't use data binding for a particular task, you will commonly be using an SqlConnection and SqlCommand with SqlCommand.ExecuteReader or SqlCommand.ExecuteNonQuery. These are quite similar to how you would use ado in asp.

Best practice is likely to be data bind where possible.

creativeedg10
05-03-2011, 03:44 PM
Thank you all for your insight and help. I am converting over to ASP.NET, got the connections to work, and so far things are coming along pretty good. I am experiencing a learning curve, but I'm willing to learn it too; so it's going well :)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum