473,383 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

What am I doing wrong?

Hi,

I'm at my wits-end here. I'm a beginner with ASP/C# (using .NET 2003)
and I'm trying to post variables from a classic ASP form to a ASP.NET
form. The Classic ASP form was scripted with VBScript whereas the
ASP.NET page is scripted with C#.

My issue is this: I have two files within the site's working directory
(PaymentPage.aspx and PaymentPage.aspx.cs). The .cs file is the
codebehind for the aspx file. Basically, I can ouput the posted
variable from the top of the aspx file using:
<% Response.Write(Request.Form["totalcost"])); %>
....but if I try to do this further down the page, nothing will show
up.

So, now I'm expecting the Page_Load() method to do the work for me
(since it's on a codebehind file) but nothing is happening there
either. Does anyone know what I'm doing wrong? The basic problem is
shown below:

PaymentPage.aspx

<%@ Page language="c#" Codebehind="PaymentPage.aspx.cs"
AutoEventWireup="false"
Inherits="Webpay.NET_CSharpASPSample.PaymentPage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Webpay.NET Start Page</title>
<meta content="VJ#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:label id="amount" style="Z-INDEX: 111; LEFT: 152px; POSITION:
absolute; TOP: 80px" runat="server" Font-Bold="True"></asp:label>
</form>
</body>
</html>

------------------------------

PaymentPage.aspx.cs

public class PaymentPage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label amount;

private void Page_Load(object sender, System.EventArgs e)
{
this.amount.Text = Request.Form["totalcost"];
}
}

-----------------------------

Thanks in advance for your help.

Regards,
Nick.
Jun 13 '07 #1
8 1385
Hi,

You have disabled firing of Page_Load by setting

AutoEventWireup="false" in the header of the ASPX file.

You should either enable AutoEventWireup or override OnLoad method.

-yuriy
Hi,

I'm at my wits-end here. I'm a beginner with ASP/C# (using .NET 2003)
and I'm trying to post variables from a classic ASP form to a ASP.NET
form. The Classic ASP form was scripted with VBScript whereas the
ASP.NET page is scripted with C#.

My issue is this: I have two files within the site's working directory
(PaymentPage.aspx and PaymentPage.aspx.cs). The .cs file is the
codebehind for the aspx file. Basically, I can ouput the posted
variable from the top of the aspx file using:
<% Response.Write(Request.Form["totalcost"])); %>
...but if I try to do this further down the page, nothing will show
up.
So, now I'm expecting the Page_Load() method to do the work for me
(since it's on a codebehind file) but nothing is happening there
either. Does anyone know what I'm doing wrong? The basic problem is
shown below:

PaymentPage.aspx

<%@ Page language="c#" Codebehind="PaymentPage.aspx.cs"
AutoEventWireup="false"
Inherits="Webpay.NET_CSharpASPSample.PaymentPage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Webpay.NET Start Page</title>
<meta content="VJ#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:label id="amount" style="Z-INDEX: 111; LEFT: 152px; POSITION:
absolute; TOP: 80px" runat="server" Font-Bold="True"></asp:label>
</form>
</body>
</html>

------------------------------

PaymentPage.aspx.cs

public class PaymentPage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label amount;
private void Page_Load(object sender, System.EventArgs e)
{
this.amount.Text = Request.Form["totalcost"];
}
}
-----------------------------

Thanks in advance for your help.

Regards,
Nick.

Jun 13 '07 #2
Generally, what you would do is to create a page level variable in your code
behind (outside any events), then, inside the Page_load event, you'd
populate it
string myVar;

then, inside the Page_Load -
myVar=request.querystring("totalcost");

Then, you can use myVar anywhere you'd like in your code, though
Response.write is not used anymore (generally, though it can be). You would
put a label wherever you need the data to show - then:
label1.text=myvar;

I've never tried to post an ASP form to an ASPX page, so I'm not exactly
sure what to encounter in that regards.
--
David Wier
MVP/ASPInsider
http://aspnet101.com
http://iWritePro.com

"Nicko." <Nicko.@discussions.microsoft.comwrote in message
news:EE**********************************@microsof t.com...
Hi,

I'm at my wits-end here. I'm a beginner with ASP/C# (using .NET 2003)
and I'm trying to post variables from a classic ASP form to a ASP.NET
form. The Classic ASP form was scripted with VBScript whereas the
ASP.NET page is scripted with C#.

My issue is this: I have two files within the site's working directory
(PaymentPage.aspx and PaymentPage.aspx.cs). The .cs file is the
codebehind for the aspx file. Basically, I can ouput the posted
variable from the top of the aspx file using:
<% Response.Write(Request.Form["totalcost"])); %>
...but if I try to do this further down the page, nothing will show
up.

So, now I'm expecting the Page_Load() method to do the work for me
(since it's on a codebehind file) but nothing is happening there
either. Does anyone know what I'm doing wrong? The basic problem is
shown below:

PaymentPage.aspx

<%@ Page language="c#" Codebehind="PaymentPage.aspx.cs"
AutoEventWireup="false"
Inherits="Webpay.NET_CSharpASPSample.PaymentPage" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>Webpay.NET Start Page</title>
<meta content="VJ#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:label id="amount" style="Z-INDEX: 111; LEFT: 152px; POSITION:
absolute; TOP: 80px" runat="server" Font-Bold="True"></asp:label>
</form>
</body>
</html>

------------------------------

PaymentPage.aspx.cs

public class PaymentPage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label amount;

private void Page_Load(object sender, System.EventArgs e)
{
this.amount.Text = Request.Form["totalcost"];
}
}

-----------------------------

Thanks in advance for your help.

Regards,
Nick.

Jun 13 '07 #3
"Nicko." <Nicko.@discussions.microsoft.comwrote in message
news:EE**********************************@microsof t.com...
AutoEventWireup="false"
AutoEventWireup="true"
--
http://www.markrae.net

Jun 13 '07 #4
Thanks for everyone's reply but I've tried everything and nothing's worked.
Setting the AutoEventWireup to be true doesn't help either. If I make a
change to the aspx file, I can at least see a change but nothing I seem to do
to the aspx.cs file is having any effect. I even tried setting the hidden
property of another label and that did nothing either.

Any other ideas?

Thanks again,
Nicko.
Jun 13 '07 #5
Can you set a breakpoint in Page_Load and see what value is assigned to Text
property? Do you reach the breakpoint?

Thanks for everyone's reply but I've tried everything and nothing's
worked. Setting the AutoEventWireup to be true doesn't help either. If
I make a change to the aspx file, I can at least see a change but
nothing I seem to do to the aspx.cs file is having any effect. I even
tried setting the hidden property of another label and that did
nothing either.

Any other ideas?

Thanks again,
Nicko.

Jun 14 '07 #6
"Yuriy Solodkyy" wrote:
Can you set a breakpoint in Page_Load and see what value is assigned to Text
property? Do you reach the breakpoint?
I haven't tried that yet. I'll give it a go today and let you know.

Thanks,
Nick.
Jun 14 '07 #7
"Yuriy Solodkyy" wrote:
>
Can you set a breakpoint in Page_Load and see what value is assigned to Text
property? Do you reach the breakpoint?
OK, that works when I'm running the project from the .csproj file - even the
changes I make in Page_Load() work!

But, what I'm doing is copying the .aspx and .aspx.cs files out of the
project's directory and pasting it into another site directory once the
project has been rebuilt. Would this be part of the problem? I'm a beginner
at this so I'm still trying to get a feel for the way ASP.NET works...

Thanks in advance,
Nick.
Jun 15 '07 #8
In ASP.NET 1.0/1.1 if you create your web site with Visual Studio you need
to build the .asp.cs files with the Visual Studio and deploy created assemblies
(DLL files) as well to the destination server.

You may try to add SRC attributes to your ASPX files to allow dynamic compilation
at your target location and avoid deploying DLLS. See: http://support.microsoft.com/kb/312311

However, as you don't get error message about not existing page base classes
it seems that you have already copied these assemblies to the target server.
When you copy your aspx and .aspx.cs target server just uses the older version
of already compiled .aspx.cs.

Try adding src attribute to @Page directive and see if it works or you get
error message.

-yuriy
>"Yuriy Solodkyy" wrote:
>>Can you set a breakpoint in Page_Load and see what value is assigned
to Text property? Do you reach the breakpoint?
OK, that works when I'm running the project from the .csproj file -
even the changes I make in Page_Load() work!

But, what I'm doing is copying the .aspx and .aspx.cs files out of the
project's directory and pasting it into another site directory once
the project has been rebuilt. Would this be part of the problem? I'm a
beginner at this so I'm still trying to get a feel for the way ASP.NET
works...

Thanks in advance,
Nick.

Jun 15 '07 #9

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

Similar topics

125
by: Sarah Tanembaum | last post by:
Beside its an opensource and supported by community, what's the fundamental differences between PostgreSQL and those high-price commercial database (and some are bloated such as Oracle) from...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
11
by: Alfonso Morra | last post by:
Hi, I am at the end of my tether now - after spending several days trying to figure how to do this. I have finally written a simple "proof of concept" program to test serializing a structure...
46
by: Keith K | last post by:
Having developed with VB since 1992, I am now VERY interested in C#. I've written several applications with C# and I do enjoy the language. What C# Needs: There are a few things that I do...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
2
by: Aaron Ackerman | last post by:
I cannot a row to this bound DataGrid to SAVE MY LIFE! I have tried everything and I am at a loss. The using goes into add mode with the add button adds his data then updates with the update...
16
by: Ajay | last post by:
Hi all, i want to know when i create a class.what all it contains.I know the following things are there by default if i do not declare them by myself.Please tell the other things that are left. ...
8
by: watkinsdev | last post by:
Hi, I have created a mesh class in visual studio 6.0 c++. I can create a device, render objects and can edit the objects by for instancnce selecting a cluster of vertices and processing the...
0
by: shapper | last post by:
Hello, I am creating a class with a control. I compiled the class and used it on an Asp.Net 2.0 web site page. I can see the begin and end tags of my control (<oland </ol>) but somehow the...
10
by: DavidSeck.com | last post by:
Hi, I am working with the Facebook API right now, an I have kind of a problem, but I don't know what I am doing wrong. So I have a few arrays, f.ex.: User albums: array(2) {
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.