[removed] Multiple parameters in __doPostBack

前端 未结 3 989
时光说笑
时光说笑 2021-01-04 05:48

First of all, the only post (calling-multiple-dopostback-from-javascript) I found about this didn\'t help my problem, so I don\'t belive this post is a duplicate.

I

3条回答
  •  轮回少年
    2021-01-04 06:28

    You could pass the two values as one JSON string:

    function OpenSubTable(bolID, controlID) {
      __doPostBack('UpdatePanelSearch', JSON.stringify({ bolID: bolID, controlID: controlID}));
    }
    

    And then parse it on the server:

    protected void UpdatePanelSearch_Load(object sender, EventArgs e)
    {
      SomeDTO deserializedArgs = 
          JsonConvert.DeserializeObject(Request["__EVENTARGUMENT"]);
      var bolID = deserializedArgs.bolID;
      var controlID = deserializedArgs.controlID;
    }
    
    public class SomeDTO
    {
        public string bolID { get; set; }
        public string controlID { get; set; }
    }
    

    If you're using .Net >=4.0, I believe you can deserialize to a generic touple and avoid having to create SomeDTO. Edit: More information about deserializing to dynamic types.

提交回复
热议问题