Why is my ASP.NET page injecting this WebResource.axd Javascript file?

前端 未结 5 1988
栀梦
栀梦 2021-01-01 02:45

When I view source on my ASP.NET page I get the following snippet:



        
5条回答
  •  温柔的废话
    2021-01-01 02:51

    The answer is a lot simpler than any I've seen here: just remove the PostBackUrl from the Button and all JavaScript disappears like magic.

    Without JavaScript, an HTML button cannot submit to another page than the page specified in

    . However, ASP.NET does provide a possibility to do this out-of-the-box if you specify a PostBackUrl on a Button. That's what the JavaScript is about: supporting a non-default post-back.

    In this specific case your PostBackUrl is the same as the 's action, but apparently ASP.NET does not special-case this and any non-empty string triggers this wrapper script.

提交回复
热议问题