我遇到了这个插件:http://malsup.com/jquery/form/#getting-started
我想知道如何在asp.net webforms中使用它?
我应该用action="comment.php"
替换什么? WEBMETHOD?
ASPX:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://malsup.github.com/jquery.form.js"></script>
<script type="text/javascript">
$(document).ready(function () {
// bind 'myForm' and provide a simple callback function
$('frmMaster').ajaxForm(function () {
alert("Thank you for your comment!");
});
});
</script>
<form id="myForm" action="Default.aspx/UPLOAD" method="post">
Name: <input type="text" name="name" />
Comment: <textarea name="comment"></textarea>
<input type="submit" value="Submit Comment" />
</form>
</asp:Content>
背后的代码:
[WebMethod]
public string UPLOAD(HttpContext context)
{
return "test";
}
注意:我正在使用母版页。