Solved

Passing Data From ASP.NET Form to ASP Page

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Using jQuery to set a DIV attribute on page load 9 29
Html5 string 3 20
"Pause" execution of javascript function for x miliseconds 2 22
asp.net mvc5 6 14
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

785 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