?
Solved

Passing Data From ASP.NET Form to ASP Page

Posted on 2012-04-04
3
Medium Priority
?
491 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 1000 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

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

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

When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
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 …
Suggested Courses

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