接著在<asp:button> 元件上用力點兩下,還真的會出現 ???_onClick 的事件處理程序,執行後,查閱網頁原始碼,真的有 ViewState 及 doPostBack:
<form name="aspnetForm" method="post" action="" id="aspnetForm">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwULLTEwOTI1OTYyNzVkZLpot9ZfQv2AVX+qzchpLZSkhxSt" />
<!--div>
<script type="text/javascript">
var theForm = document.forms['aspnetForm'];
if (!theForm) {
theForm = document.aspnetForm;
}
function __doPostBack(eventTarget, eventArgument) {
if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
theForm.__EVENTTARGET.value = eventTarget;
theForm.__EVENTARGUMENT.value = eventArgument;
theForm.submit();
}
}
</script>
註:環境=MVC 2, 在 VisualStudio 2008
沒有留言:
張貼留言