Solved

Passing Data From ASP.NET Form to ASP Page

Posted on 2012-04-04
3
458 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

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

688 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