Try to use the following example code
OnClientClick='document.frames["iframe1"].document.forms[0].submit(); return false;'
You can get the reference to the form id of page B, whose form seems is placed in the its masterpage. But the <form> tag contains runat="server". When it contains runat="server" then if you add the action="XXX.aspx" will not work at run time. In a short, you should find the form's action attribute is the current page at runtime( looking at source file from client).
Johnson