سؤال

I have an applicationPage who is open by Modal Dialog. I would like to read this params server side in the application page . I don't use the URL for passing parameter, i use the options.args

Is it possible??

sample code :

Javascript :

var options = {
  url: '/_layouts/MyApplicationPage.aspx',
  title: 'Title',  
  autoSize: true,   
  args: { arg1: 'arg 1', arg2: 123, arg3 : 'other arg'} // My params
};
SP.UI.ModalDialog.showModalDialog(options);

Server side of MyApplicationPage.aspx

protected void Page_Load(object sender, EventArgs e){   
  // how to read arg1, arg2, arg3 ??
هل كانت مفيدة؟

المحلول

You probably won't be able to get the args in code-behind when you specify them within the options object. When working with the options object in Modal Dialog the args will be saved on client side only. Thus the server cannot get them.

To get these args you should modify your url like this:

var options = {
  url: '/_layouts/MyApplicationPage.aspx' + '?arg1=arg%201&arg2=123&arg3=other%20arg',
  title: 'Title',  
  autoSize: true,   
  args: { arg1: 'arg 1', arg2: 123, arg3 : 'other arg'}
};

This way you can get them with Request.Form["arg1"] As you can see, I did escape the arguments.

نصائح أخرى

Please try below line to get args from modal dialog

Request.Form["args"]

You can refer below mentioned link to get some more idea on it.

SharePoint: How to pass parameters into a Modal Dialog Window and then access them

Please let me know if it does not work.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى sharepoint.stackexchange
scroll top