Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
458 views
in Technique[技术] by (71.8m points)

webforms - Multiple forms on ASP.NET page

Coming from a Classic ASP background, I'm used to multiple forms on a page, but this clearly limited in a ASP.NET page.

However, I have a situation where I have a form that gathers input from the user, saves the data to a DB, and afterwards I want to render (and tweak the values of) a special form that posts to the PayPal website.

If the PayPal form's field values were static, there would be no problem, but since I want to manipulate the form server-side (to tweak the qty, desc, price fields etc) this will be a problem.

I was considering redirecting to a different page after writing to the DB, and I suspect this would work fairly well, but it's a bit of extra effort that may be unneccessary.

It has also been suggested to me that I could programmatically render a different form, depending on where in the cycle I am. That is, use a placeholder, and on Page_Load I would add a DB Form (complete with child controls) initially, and the PayPal form after a Postback.

This scenario has got to be a common one for you guys, so I'm looking for opinions advice and any relevant code samples if you have preferred approach.

I know I can get by, but this project is a learning vehicle so I want to adopt what passes for best practice.

Thanks in advance...

Chris

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can have multiple forms, it's just only one form may have the runat="server" attribute.

There are a bunch of answers to getting PayPal to work; but as it's a learning vehicle that may be cheating. In all honesty, I'd look at the full-blown PayPal API rather than use the method of the somewhat simplistic form (with the added advantage that it should stretch your learning more).

Otherwise yes, set up an HTML form outside of the server side form, and add a literal into it and write the bits and pieces in there.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...