I have adapted the Umbraco create context menu item in order to duplicate content. I have been working through it sorting small problems but I am now stuck. When trying to use the dialogHandler_temp.Create() method I am getting a NullReferenceException.
All of the variables used are not null nor is the page. Does anyone have an idea how I could sort this?
private void DoCreation()
{
if (!Page.IsValid)
return;
var hel = helper.Request("nodeType");
var nType = int.Parse(nodeType.SelectedValue);
var nId = int.Parse(Request["nodeID"]);
var rName = rename.Text;
var cur = Current;
if (cur != null) // dialogHandler_temp.Create() is a static method
cur.ClientTools.ChangeContentFrameUrl(dialogHandler_temp.Create(hel, nType, nId, rName)).CloseModalWindow();
}
Stack trace:
[NullReferenceException: Object reference not set to an instance of an object.]
umbraco.presentation.create.dialogHandler_temp.Create(String NodeType, Int32 TypeId, Int32 NodeId, String Text) +278
OptionalMultiLangPage.DoCreation() in c:\inetpub\wwwAmaris\optional_multiLang.aspx.cs:112
OptionalMultiLangPage.SbmtClick(Object sender, EventArgs e) in c:\inetpub\wwwAmaris\optional_multiLang.aspx.cs:96
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +154
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3803
I got this sorted. It took me a while to realise that
helper.Request("nodeType")wasn’t to return the new node’s type, rather the xml node value of what is being done. This must be assigned somewhere out-with the the Umbraco Content class so I missed it. It should be set to the value of"content".My code now looks like: