Solved

Passing Data From ASP.NET Form to ASP Page

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
css, html 6 31
HTML button disabled 11 36
JavaScript error 1 34
Bootstrap 3 and Angular 2 12 25
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.
Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …

743 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now