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
{
get
{
return _hostname;
}
set
{
_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;
SP.UI.ModalDialog.showModalDialog(options);
}
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?
Greetz