4

I inherited an application that used forms to POST data. I am not very familiar with Form behavior. To me, this is an arcane method of doing a POST. Plus, these forms break hardcore when converted to MasterPages because of Forms Nesting.

So I am refactoring, trying to minimize the dmg I'm doing. Are these two functionally equivalent?

Original method

<form id="transferForm" action="TransferSave.aspx" method="post">
<input type="button" id="Button2" class="button" onclick="transferForm.submit();" value="Review Transfer"/>

New way

<asp:Button ID="submitBtn" runat="server" class="button" Text="Review TransferX" PostBackUrl="TransferSave.aspx" />

I tested the new method and it worked. I just want to be sure that what I am doing doesn't create some nutty problem that I am unaware of. Mainly because I just don't feel like a master of html forms.

Community
  • 1
  • 1
P.Brian.Mackey
  • 43,228
  • 68
  • 238
  • 348

1 Answers1

4

Is some different... At First PostBackURL does post to the same page and then redirects sending the form values, but not only the values you desired, ALL CONTROLS are sended...

Alberto León
  • 2,879
  • 2
  • 25
  • 24
  • +1 cool, if that's all I dont mind sending too much information. If it noticeably hurts performance AND I get the time to refactor the heck out of this application I will deal with it then. At this point I am just trying to finish within a few days time. – P.Brian.Mackey Apr 06 '11 at 17:42
  • @P.Brian.Mackey Another way is submit the postback, then clear the response and add to page with Response.Write the form and fields as traditional html. Then, by javascript onload do the classic submit. – Alberto León Apr 08 '11 at 07:52
  • @P.Brian.Mackey And more... use JQuery, and build the form values to do a $post – Alberto León Apr 08 '11 at 07:53