In my web part I use the create_DialogOptions JS function to create a new aspx site as a dialog box. That works fine. Now I would like to have access to the custom properties from the web part.

I tried it like this: public ProjectName.WebpartName.WebpartName(Class) WebPartProperty { get; set; } Now if I try to access to the properties, I get a null reference. (I new its senseless, but I would have a try :)) I don’t know how I could do this. Is it any way possible to get access to those properties?

It would be nice if someone could help me.

Edit: I think I could do it, with the consumer, provider model. I will have a try. If there is a better solution, let me know.

Edit2: Well, the consumer, provider model doesn't work . I can't connect the aspx site.

Add some code:

@tim-gabrhel You are right! Here some code:

I have created a visual web part and added some personal properties to the web part. For example hostname:

private string _hostname = string.Empty;
[WebBrowsable(true), WebDescription("Hostname"), WebDisplayName("Hostname"),
Personalizable(PersonalizationScope.Shared), Category("Webpart Settings")]              
public string hostname 
        return _hostname;
        _hostname = value;

In the

public partial class WebPartNameUserControl : UserControl

class, I call public WebPartName WebPartProperty { get; set; } and get access to the properties.

I use the create_DialogOptions() JS function to create a new dialog window, where the user could insert some stuff.

function ShowDialog() {
    var options = SP.UI.$create_DialogOptions();
    options.url = "/_layouts/ProjectName/Dialog.aspx";
    options.width = 600;
    options.height = 300;

Now I need access from the dialog to the web part property. How could I get the hostname from the properties?

I hope my problem is now more understandable .

Edit 4:

I found a way, how I could access to the custom properties. I add at the Page_Load() the properties to a session[""], after that, I could use the values in my dialog.

session["test"] = propertyOne;
string value = (string)session["test"];

Are they any disadvantages for that solution? A normal provider, consumer model is not possible?


  • I think you're going to need to provide some code samples as to what you're doing to get further help Nov 7, 2011 at 14:31

2 Answers 2


Another alternative would be to use the SP.UI.Dialog.args object which would allow us to pass arbitrary properties into the dialog. This could be inturn retrieved from the opened page using the SP.UI.ModalDialog.get_childDialog().get_args() property.

Please read this detailed post to find how its implemented - http://www.chaholl.com/archive/2010/11/17/using-the-dialog-framework-in-sharepoint-2010.aspx

  • Okay, this alternative is nice, if the information doesn’t contain sensitive data. In my case, I needed a safer way, so I decided to use the session. Thanks for your replay, good to know that there are more ways to do that. Greetz
    – user5167
    Nov 10, 2011 at 7:16

This post tells:

For a practical example of the deployment and use of pages for modal dialog boxes, including how to pass information to the modal dialog box, see the Full-Trust Proxy Reference Implementation. For more information about using the SharePoint client object model in JavaScript, see ECMAScript Object Model Reference on MSDN.

  • I’m sorry, that doesn't help me. In the article they use a sandbox solution. I use a farm web part. I also don’t find a passage, where they access a custom property from the calendar dialog, or have I missed something? Greetz
    – user5167
    Nov 7, 2011 at 15:37
  • yes, you are right.
    – Alexander
    Nov 7, 2011 at 16:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.