Solved

Passing Data From ASP.NET Form to ASP Page

Posted on 2012-04-04
3
443 Views
Last Modified: 2012-05-09
I am trying to pass some data between a ASPX page and ASP page.

Bit of background data; I am reasonably proficient in ASP and HTML development unfortunately I needed to use ASP.NET to retrieve a client HostName as part of an Agreement page, as proof as where Terms & Conditions where agreed to. This is then to be passed over an ASP page which emails the details to me.

However I simply cannot get the ASP page to use the request.form() function as it returns a null value. So without trying to learn ASP.NET I am wondering if there is a way to pass this data across?

Here you can see the form code and taged in the <asp> is the .net label which shows the hostname (when made visible)

   
 <div align="center">
	<form method="post" action="agreed.asp" name="mltc">
                    <label for="name">Name</label>
                    <input type="text" name="user_name" size="50">
                    <div id="termsframe">
                                <iframe  style="WIDTH: 600px; HEIGHT: 385px" name="shares2" src="medialibrary_termsconditions.html" frameborder="1" width="400" height="400" scrolling="yes"></iframe>
	</div>
                   <br>
        <asp:Label ID="Label1" name="Label1" runat="server" Text="Label" Visible="false"></asp:Label>
                    I Agree
                    <input type="checkbox" name="agree" onclick="enable(this);">
                    <input type="submit" id="submit" name="submit" disabled="disabled" value="SUBMIT">
                    </form>	
		</div>

Open in new window


Here is the asp code I use to retrieve the data and you can see how I would have expected it to retrieve the Label1 based on its ID.

 
strComputerName=request.form("Label1")
 username=request.form("user_name")
 date_time=now

Open in new window


Obviously this is not the case and the email that is sends proves this as you should hopefully see from the image embedded there is no From: field data.

Email sent using ASP page
Anyone who knows the easiest way to fix this with ASP will be much appreciated.
0
Comment
Question by:piemckay
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Expert Comment

by:Vishal Kedar
ID: 37805916
try below code


Request.Form["myVar"] for POST
Request.Form["myVar"] ="test";
or
Request.QueryString["myVar"]="test";


Request.QueryString["myVar"] for GET
string str =Request.QueryString["myVar"];

or check below link
http://forums.asp.net/t/1188876.aspx/1
0
 

Author Comment

by:piemckay
ID: 37806608
I'm rather confused about this code, I'm assuming you could use the QueryString in replace of Form here?

strComputerName=request.form("Label1")

Open in new window


But if I used, this which looks more like C#

Request.QueryString["myVar"]="test"; 

Open in new window


It would not work so changing the syntax to VB:

Request.QueryString("Label1")="strComputerName"

Open in new window


This would imply Label1 is equal to strComputerName (as a string) but even without the quotes it would be incorrect.

Again if you meant for me to switch the variables so

Request.QueryString("strComputerName")="Label1" 

Open in new window


That would imply I am requesting strComputerName and setting that to Label1.

Again like I said I have little experience with ASP.NET and have never used the QueryString to request in this context. I would have assumed it would have been.

strComputerName =Request.QueryString("Label1") 

Open in new window


This would have been more to what I am use to, but I have tested it, as well as the suggestions you gave in the manner I explained and just got errors and null returns.

Prehaps I am just not understand how this code is used properly? Could you explain more?
0
 
LVL 5

Accepted Solution

by:
Vishal Kedar earned 500 total points
ID: 37807276
Write below code in your asp page ie set the value

Request.Form("strComputerName")="piemckay" //piemckay is your computer name


Write below code in your asp.net page in page_load event ie get the value.

str = Request.QueryString("strComputerName")  //str is your string variable.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question