473,467 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

can't run classic asp code in header of aspx file

I'm trying to do some ASP date formatting in a separate include file
on my .aspx page, but I keep getting "Statement cannot appear within
method body, expected end of statement" error when running this page.
The header code begins as:
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<!-- #include file=dayofweekparse.asp -->

<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim strConn as string
="SERVER=xxx.xxx.xx.xx;UID=xxxx;PWD=xxxx;DATABASE= xxxx;"
Dim strSQL as string ="select events from EventTable"
Dim Conn as New sqlConnection(strConn)
Dim Cmd as New sqlCommand(strSQL,Conn)
Conn.Open()
thedata.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata.DataBind()
End Sub
</script>
????????

Chumley
Nov 18 '05 #1
6 1376
I doubt you'll have much luck trying to mix ASP and ASP.NET in the same page
like that. They are run by two completely separate engines, so this kind of
thing is not supported.
If you really need them to display together you might be able to get away
with putting an ASP page in one frame and an ASP.NET page in another frame.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net
"Chumley the Walrus" <sp*******@yahoo.com> wrote in message
news:1e*************************@posting.google.co m...
I'm trying to do some ASP date formatting in a separate include file
on my .aspx page, but I keep getting "Statement cannot appear within
method body, expected end of statement" error when running this page.
The header code begins as:
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<!-- #include file=dayofweekparse.asp -->

<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim strConn as string
="SERVER=xxx.xxx.xx.xx;UID=xxxx;PWD=xxxx;DATABASE= xxxx;"
Dim strSQL as string ="select events from EventTable"
Dim Conn as New sqlConnection(strConn)
Dim Cmd as New sqlCommand(strSQL,Conn)
Conn.Open()
thedata.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata.DataBind()
End Sub
</script>
????????

Chumley

Nov 18 '05 #2
well i would suggest using iframe and set the src to the asp page you want
to display within asp.net page.

otherwise look up webclient class. you can refer to the asp file seperately.
read it into a string and then assign the html to a table cell

if you need any reference on specifics just let me know

--

Regards,

Hermit Dave
(http://hdave.blogspot.com)
"Chumley the Walrus" <sp*******@yahoo.com> wrote in message
news:1e*************************@posting.google.co m...
I'm trying to do some ASP date formatting in a separate include file
on my .aspx page, but I keep getting "Statement cannot appear within
method body, expected end of statement" error when running this page.
The header code begins as:
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<!-- #include file=dayofweekparse.asp -->

<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim strConn as string
="SERVER=xxx.xxx.xx.xx;UID=xxxx;PWD=xxxx;DATABASE= xxxx;"
Dim strSQL as string ="select events from EventTable"
Dim Conn as New sqlConnection(strConn)
Dim Cmd as New sqlCommand(strSQL,Conn)
Conn.Open()
thedata.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata.DataBind()
End Sub
</script>
????????

Chumley

Nov 18 '05 #3
Of course this won't work. The include file becomes part of the .aspx page,
which expects .NET code. You can't put classic ASP there, unless its .NET
equivalent happens to be the same.

"Chumley the Walrus" <sp*******@yahoo.com> wrote in message
news:1e*************************@posting.google.co m...
I'm trying to do some ASP date formatting in a separate include file
on my .aspx page, but I keep getting "Statement cannot appear within
method body, expected end of statement" error when running this page.
The header code begins as:
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<!-- #include file=dayofweekparse.asp -->

<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim strConn as string
="SERVER=xxx.xxx.xx.xx;UID=xxxx;PWD=xxxx;DATABASE= xxxx;"
Dim strSQL as string ="select events from EventTable"
Dim Conn as New sqlConnection(strConn)
Dim Cmd as New sqlCommand(strSQL,Conn)
Conn.Open()
thedata.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata.DataBind()
End Sub
</script>
????????

Chumley

Nov 18 '05 #4
Scott Simons wrote:
asp != asp.net there is no #include. Also, there is built in datetime
parsing capability.


If there was no built in capability, what would be the best solution for
this situation? Would a user control (.ascx) be appropriate for this
situation? And just have that display the value?

Nov 18 '05 #5
As others have mentioned, there is no #include style solution to your
problem. I've done this before though, and I imagine others have too,
as it seems like a likely thing to come up when you're halfway through
porting an asp app to .NET.

Basically, you'll need to do a web request to the .asp file that you
want to include, then spit the HTML out into your file.

Check out System.Net.WebRequest for ideas.

Jason
---

Expat Software Consulting Services
http://www.expatsoftware.com/

sp*******@yahoo.com (Chumley the Walrus) wrote in message news:<1e*************************@posting.google.c om>...
I'm trying to do some ASP date formatting in a separate include file
on my .aspx page, but I keep getting "Statement cannot appear within
method body, expected end of statement" error when running this page.
The header code begins as:
<%@ Page Language="VB" debug="true"%>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SQLClient" %>
<!-- #include file=dayofweekparse.asp -->

<script language="VB" runat="server">
Sub Page_Load(Src As Object, E As EventArgs)
Dim strConn as string
="SERVER=xxx.xxx.xx.xx;UID=xxxx;PWD=xxxx;DATABASE= xxxx;"
Dim strSQL as string ="select events from EventTable"
Dim Conn as New sqlConnection(strConn)
Dim Cmd as New sqlCommand(strSQL,Conn)
Conn.Open()
thedata.DataSource =
Cmd.ExecuteReader(system.data.CommandBehavior.Clos eConnection)
thedata.DataBind()
End Sub
</script>
????????

Chumley

Nov 18 '05 #6
Dwight Rau <dw*******@yahoo.com> wrote in news:emVMrY3mEHA.2340
@TK2MSFTNGP11.phx.gbl:
If there was no built in capability, what would be the best solution for
this situation? Would a user control (.ascx) be appropriate for this
situation? And just have that display the value?


Redo the code in .NET. Your code looks pretty straightforward.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 18 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Chumley the Walrus | last post by:
I'm trying to do some ASP date formatting in a separate include file on my .aspx page, but I keep getting "Statement cannot appear within method body, expected end of statement" error when running...
1
by: Steve | last post by:
I have mixed ASP.NET and classic ASP apps environment, ASP.NET needs to invoke classic ASP. I had problems to put these two apps in the same site(or vir-dir). It seems that IIS gets confused by...
3
by: Brian Birtle | last post by:
**** A CHALLENGE TO THE GURUS - refute the statement "It's impossible to build a file upload progress meter using ASP.NET" **** First person to prove me wrong gets "All Time .NET Programming GOD"...
2
by: | last post by:
I have a breakpoint in an aspx page that I'm using to try to trap some code to see what's going on. I'm translating a page that is working in a traditional ASP page, which takes several session...
3
by: bill | last post by:
I need to open a asp.net web form from a classic asp page, and pass a username and password to the asp.net page. The username and password exist as session variables in the classic asp...
2
by: Bob | last post by:
In classic ASP, I used to keep a constant file that contains site configuration settings. For example, Const SITE_BACKGROUND_COLOR = "#909090" Const APPLICATION_NAME = "My Financial Site"...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
9
by: KenLee | last post by:
I made an application which includes classic asp page and asp.net page. when I tried to redirect from classic asp page to asp.net 2.0 page, it works under my local IIS directory. ex) <a...
11
by: =?Utf-8?B?c2NodXJzdDMw?= | last post by:
Hi, I am currently trying to get back into ASP and have begun looking at an old webpage I developed some years ago, it was fully functional back in 2002 and I had it up and running with no...
4
by: =?Utf-8?B?RHlsYW5TbWl0aA==?= | last post by:
Is there an end-of-support date for Classic ASP? For example, I know that VB6 standard support ended sometime around March 2005, and extended support was available until around March 2008. Is...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.