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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can you mix ASP and .NET pages?

Status
Not open for further replies.

creativeedg10

Technical User
Feb 16, 2011
10
US
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.
 
ASP and ASP.NET do not directly communicate with each other or share any kind of state (including session variables).

But you can grab the Classic ASP Session variables, construct a dynamic form in a new Classic ASP page consisting of their names and values as hidden form fields, and submit it to ASP.NET page.

You can find the details here:
 
Thank you for your help AzizKamal. I will look into your resource link. Looks like I'm starting to code .NET by scratch at the moment, so I've been doing some heavy reading and study on this structure.

The biggest challenge I'm trying to simply get through is establishing a database connection to where I have good flexibility as to what is displayed out. I just want a data read, but I want it to only read specific areas of the table. The reading so far is making sense, but I'm sure I'll run into some obstacles once I try coding it myself. This seems like a basic concept because of its common use, so I'm hoping for the best. :)
 
In ASP.NET, it is not necessary to store connection strings in web.config file. You can also build the connection string on the fly.

Here is the code that I used in one of my application. Backend database is Oracle.

Code:
Imports System.Data
Imports System.Data.OracleClient

Partial Class Units
Inherits System.Web.UI.Page
Dim cn As OracleConnection = New OracleConnection

cn.ConnectionString = "Data Source=" & Session("servername") & ";User Id=" & Session("username") & ";Password=" & Session("password") & ";Integrated Security=no;"
cn.Open()

This thread also has relevant info.
thread855-1610339
 
Thank you for your help. This is a good start for me to work from in the ConnectionString understanding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top