I have a website in asp.net and I am working on creating AMP pages at http://mywebsite.com/amp/......
I was able to make all the necessary changes for AMP except the following error.
The attribute 'action' may not appear in tag 'FORM [method=POST]'
the Form tag in my website looks like this
<form name="form1" method="post" id="form1">
AMP tutorial suggest to use action-xhr=/default.aspx instead of action="default.aspx
here is the source: https://ampbyexample.com/components/amp-form/
Now, the thing is how to remove action attribute and add action-xhr attribute in asp.net.
I tried following code in cs file but no luck.
this.Page.Form.Attributes.Remove("action");
Please note JavaScript and jQuery are not allowed in AMP
Take a look at the MSDN documentation, where it talks about an
ActionlessForm. You basically inheritHtmlForm, and replace the form tag on the aspx page with your new control. You'll have to replace a bit of code like they suggest with the following:Worked like a charm for me. You may need to replace
this.Actionwiththis.Page.Request.Path, and you may find that you need to also add atargetattribute, but this will definitely put you on the right path.