问题
Just wanted to share a discovery when using Google Tag Manager (GTM) and two submit buttons in a form-tag (common legacy asp.net Webforms tech).
GTM is used by website editors. So the developers doesnt need to be involved when other scripts or event needs to be implemented or traced.
The problem is that something in GTM is making our form to always trigger the default submit button (the first in order is default).
Example problem/how to reproduce: in a wizard scenario, with back and next submit buttons, which are triggering a postback. Click on next is triggering the back button.
Removing the GTM code, and it works.
This is a legacy site. Maybe a legacy issue, but the site worked until we implemented GTM.
You may ask me now, what components are we using in GTM. Well google analytics is one, then i don't know.
Regards.
回答1:
Work-around solution: I had to rebuild the HTML to NOT use "input type=submit". Instead use buttons without submit behavior. eg not use "postbacks" on one of the buttons.
Probably something for the GTM team to look at or inform.
来源:https://stackoverflow.com/questions/41717000/issue-with-gtm-and-asp-net-webforms-with-two-submit-buttons