Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Microsoft: ASP.NET FAQ

ASP.NET Forum General Use

Pass form values from asp.net page to standard asp page by JoDaCoda
Posted: 10 Feb 05

This code will allow you to pass values from asp.net controls to a standard asp page.  The problem is standard asp pages don't recognize the forms that house .net controls because the forms are run at the server.  You must have a form that is not running at the server for the asp page to retrieve values from.  Since asp.net requires the form to run at the server, you must make two forms on your page.  form1 is for objects that the asp page is to read from.  form2 is for the asp.net controls.  I put an html button on form2 that has javascript attached to its onclick event.  The javascript fetches the values from form2 and puts them in form1, then submits form1 back to the asp page.

HTML code:
<form id="form1" name="form1" method="post" action="somepage.asp">
    <input type="hidden" name="field1" id="field1">
<form id="form2" runat="server">
    <asp:dropdownlist id="ddlItems" runat="server" Width="376px" AutoPostBack="True"></asp:dropdownlist>
    <input id="btnSubmit" style="WIDTH: 73px; HEIGHT: 24px" type="button" value="Go" onclick="SetAspForm();">

function SetAspForm()
    var obj = document.form2.ddlItems;
    var objIndex = obj.selectedIndex;
    document.form1('field1').value = obj(objIndex).value;

Back to Microsoft: ASP.NET FAQ Index
Back to Microsoft: ASP.NET Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close