Posting data from a ASP.Net Page to a Classic ASP 3.0 Page

Asked By 100 points N/A Posted on -
qa-featured

Hello,

I am currently involved in converting an existing web site to ASP.Net. The existing website is designed using classic ASP 3.0.

We are building new components in ASP.Net that require submitting information to existing ASP pages. There are pages that require the information to be "posted". That is, they should come in the "form" object in the request. I could not find a native .Net method of achieving a form post to a different URL within a .Net page.

I have found methods implemented in various forms. Some have used JavaScript, some have used an intermediate page and some have used a response.redirect and had modified the target page to read from a query string.

I am not sure which method is appropriate. Appreciate if someone can guide me on the correct track.

SHARE
Best Answer by TechnoHat
Answered By 0 points N/A #89230

Posting data from a ASP.Net Page to a Classic ASP 3.0 Page

qa-featured

Hi Avanthi,

The ASP.Net page model does not support arbitrary posting of information to alternate URL. It supports only "post backs" or posting information back to the original form.

The reason is that each form contains server-side controls, which are part of its component tree. Each form/page has its own component tree. When you press a button to invoke an action, it creates a post back. The lifecycle is:

  1. On each post back the component tree is re-generated.
  2. Posted parameters are read from the request.
  3. View state information is read.
  4. Each components' properties are initialized with the default values.
  5. Each components' properties are set from the post and view state info.
  6. Finally the method is executed.

As a security measure, a form's component tree can only be generated by the original form. A different page will not have the logic of re-generating the component tree of the calling form. Therefore you are not able to submit information to a different form rather than its own.

It has its merits and de-merits. In your case, you are experiencing a demerit because in Classic ASP 3.0 you were able to randomly post data to different URLs; even to URLS that are not hosted in the same domain!

I recommend using the redirect option and modifying the destination page to read data from the query string. This is because you can build the query string with the exact parameter names and values and redirect the user automatically.

Answered By 100 points N/A #89231

Posting data from a ASP.Net Page to a Classic ASP 3.0 Page

qa-featured

Thank you iRandom.

I did experiment using redirection, but it does not solve my problem.

You see, the .Net page is contained inside an IFRAME of the classic ASP 3.0 website. When i use redirection, the destination page (which is a classic ASP page) shows inside the IFRAME.

What i want to do is to open the destination classic ASP page in a new window or as a pop up.

Please see below image. The reservation box is a .Net page inside the IFRAME whereas the main site is in classic ASP 3.0.

As you can see, if I use redirect, the destination page (which is quite bigger that the size of the IFRAME) opens inside it.

Answered By 0 points N/A #89232

Posting data from a ASP.Net Page to a Classic ASP 3.0 Page

qa-featured

Hmm.

I see you have a definite problem here. Well, bottom line is you definitely cannot use redirect.

The options left are using a JavaScript code or using an intermediate client page.

I would suggest you give it a go with JavaScript. You can define a JavaScript method in the head of the ASP.Net page.

This code will open the destination URL using the window.open method.

Then on your submit button you add a small code to the onload event of the form to call the JavaScript method.

This will automatically open the window when the .Net page returns back. So the IFRAME page will remain as it is and the user will see a new window pooping up.

Hope this will solve your problem.

Answered By 100 points N/A #89233

Posting data from a ASP.Net Page to a Classic ASP 3.0 Page

qa-featured

As advised, I modified the page to use a JavaScript that would fire on form load. Unfortunately this method is triggering the browsers pop up blocker :(.

Otherwise it works perfectly fine.

Pop up blockers are becoming a norm in all browsers. It has become a common trend to have a pop up blocker active. Is there a method in JavaScript that could avoid triggering the pop up blocker ?

Best Answer
Best Answer
Answered By 0 points N/A #89234

Posting data from a ASP.Net Page to a Classic ASP 3.0 Page

qa-featured

Please try the following:

Add a "normal" form tag to the page somewhere in the bottom.

  1. Give it a name (Example: from Target).
  2. Set the action to the desired ASP page where you want to submit the information.
  3. Put the method as post.
  4. Set the "target" property of the form as "_blank".
  5. Now modify your JavaScript method to call the following:

document.from Target.submit();

This will submit the second form and will not trigger the pop up blocker.

Answered By 100 points N/A #89235

Posting data from a ASP.Net Page to a Classic ASP 3.0 Page

qa-featured

I tried out TechnoHat's suggestion; it seems to work!

The only drawback is that the destination page comes up in a big window. I modified the destination page and added more JavaScript code to resize the window. Something is better than nothing!

Thank you guys! You all were brilliant. I learnt a lot from this thread!

Hats off to TechnoHat 🙂

PS: iRandom I value your input as well.

Answered By 0 points N/A #89236

Posting data from a ASP.Net Page to a Classic ASP 3.0 Page

qa-featured

TechnoHat… your suggestion does work.

I stand humbled!

Login/Register to Answer

Related Questions