• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

ASP.net postbacks and posts

brandonb

Diamond Member
Hi all,

I have a question.

We have a web application at work where it contains some data stored in a webpage, they have the ability to call an external web app. This web external app can do whatever, but it needs to post back to the original webpage with the original variables intact that was within the original webpage + anything this external app wants to add/change. These variables are sent to the external web app via a post with hidden variables. So I need fill out some of these hidden variables with the logic in the external app.

I'm trying to do this with asp.net but I'm running into trouble with it because of its post backs. In this external webapp, I have an <asp::GridView> that I can select a row. This requires my external webapp to contain a form that calls itself so the GridView select can work and fill out the hidden variables found in the external webapp. Once the external webapp fills out the variables (hidden within itself as hidden variables) I need to then post back to the original webpage as a post with the hidden variables fill out.

I can't seem to figure out how to do that in asp.net. Since you can only have 1 form that posts back to itself, I can't seem to add a form post back to the original website. I'm sure this has come up a billion times before so I'm sure someone has an answer for me. Can anybody shed some light on this?

In other words as I'm not good at explaining:

original webpage contains:
form with a post action to external app URL: default.aspx

default.aspx contains:
form with a post action to itself default.aspx to it can figure out which grid row that was clicked/selected.

How do I get this default.aspx which loops to itself to post back to original webpage with values gathered from default.aspx?

Things I've tried:
1) Having the default.apx post bak to original webpage, but the code does not get called to update the hidden variables, so anything it does basically gets dropped/discarded, and I lose what it's supposed to do:
2) Create another FORM on another button outside of the existing form that goes back to the original app, but I can't runat="server" so therefore, I'm not able to get the original Request.Form() values added to this form. It alsos seems to cause a bunch of viewstate errors. So I assume this is a naughty way to do it.
3) I was thinking of using the PostbackURL but it seems that it would skip over over the logic like in instance #1 listed above. So, would I have to have the select on the grid post to itself, then have a save button do the PostbackURL back to the original website?
4) Another option you guys can give me?


Thanks.
 
Last edited:
If it is not necessary for the client to actually go back to the original website - only that the form is posted, then you should simply send it via an httpwebrequest.

If it is neccessary, I'd likely add on another form, and pass the values to it via javascript emitted server side.

If JS is unnacceptable, you could probably abuse HTMLLiterals to get the same result. If it starts with < / form>, it will seem to close the server side form, and then you can put in tags for a new one.
 
Back
Top