Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass form values from asp.net page to standard asp page

ASP.NET Forum General Use

Pass form values from asp.net page to standard asp page

by  JoDaCoda  Posted    (Edited  )
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>
<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();">
</form>



javascript:
function SetAspForm()
{
var obj = document.form2.ddlItems;
var objIndex = obj.selectedIndex;
document.form1('field1').value = obj(objIndex).value;
form1.submit();
}
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top