ASP.Net WebForm JQuery 呼叫 CodeBehind方法 (手動postback)

ASP.Net WebForm JQuery 呼叫 CodeBehind方法 (手動postback)

JQuery

  1. $('#myTextBoxB').keypress(function (e) {
  2. if (event.which == 13) {
  3. blockUI();
  4. var param = '{ ' +
  5. '"Event":"keypress", ' +
  6. '"A":"' + $("#myTextBoxA").val() + '", ' +
  7. '"B":"' + $("#myTextBoxB").val() + '"' +
  8. ' }';
  9. //第1個參數 eventTarget, 第2個參數 eventArgument
  10. __doPostBack("<%=this.myTextBoxB.ClientID%>", param);
  11. }
  12. });

Code Behind

  1. protected void Page_Load(object sender, EventArgs e)
  2. {
  3. if (!IsPostBack)
  4. {
  5. }
  6. else
  7. {
  8. string eventTarget = Request.Params.Get("__EVENTTARGET");
  9. string eventArgument = Request.Params.Get("__EVENTARGUMENT");
  10. ParamData PData = Newtonsoft.Json.JsonConvert.DeserializeObject<ParamData>(p_EventArgument);
  11. if (PData.Event == "keypress")
  12. {
  13. //處理還輯
  14. }
  15. }
  16. }
  17. public Class ParamData
  18. {
  19. public string Event {get; set;}
  20. public string A {get; set;}
  21. public string B {get; set;}
  22. }

 

 

留言

這個網誌中的熱門文章

ORA-12514: TNS: 監聽器目前不知道連線描述區中要求的服務

Oracle 工作排程 DBMS_JOB 筆記

Oracle 例外控制(Exception Control)