I'm having some trouble with a custom datatype in a Doc2Form eh, form.
The form works perfectly without the control, and the control always works. It's just a label that checks the querystring for a nodeid and shows the nodename of the node with that id. Yet every textfield or button that's supposed to show below that label doesn't get rendered. I had another simple user control on the same page that shows text after a button click and when i click it, the remaining fields of the form appear. So i guess it's a postback issue.
I'm rather new to creating usercontrols and datatypes in .net for Umbraco so i'm sure i've overlooked something.
Sounds like it's not a large control, can you post the code behind and html source for your user control? Might save some of the back and forth questions.
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using umbraco.presentation.nodeFactory;
namespace UmbracoCustomDatatypeNodenameByQs
{
public partial class NodenameByQs : System.Web.UI.UserControl, umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor
{
public string umbracoValue;
public int nodeid;
Node mynode;
protected void Page_Load(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(Request.QueryString["id"]))
{
nodeid = int.Parse(Request.QueryString["id"]);
mynode = new Node(nodeid);
Label1.Text = mynode.Name;
}
}
public object value
{
get
{
return umbracoValue;
}
set
{
umbracoValue = value.ToString();
}
}
}
}
I was having this same issue. After digging into it a bit I found that the Doc2Form.cs was calling the set method of my custom datatype and passing it a null value. This, of course, throws the dreaded 'Null Reference Exception' in the set method when using "value.ToString()'. However the error gets suppressed by a try/catch block. So it doesn't tell you what the error is. It just quits building the form.
Fortunatelyl, the fix for this is very easy. In the 'Set' method of any custom datatype, check the 'value' for null and set a default value if null is passed. Here's an example of my 'Value' property from my custom datatype.
public object value { get { myvalue = string.Empty;
foreach (ListItem item in ddlmyvalues.Items) { if (item.Selected) myvalue = item.Value; } return myvalue; } set { if (value == null) value = string.Empty; myvalue = value.ToString(); } }
I hope this helps anyone else out there having the same problem. If you find that it solves your problem please mark this post accordingly. Also a High Five would be much appreciated.
Doc2Form not rendered after custom dataype
Hi all,
I'm having some trouble with a custom datatype in a Doc2Form eh, form.
The form works perfectly without the control, and the control always works. It's just a label that checks the querystring for a nodeid and shows the nodename of the node with that id. Yet every textfield or button that's supposed to show below that label doesn't get rendered. I had another simple user control on the same page that shows text after a button click and when i click it, the remaining fields of the form appear. So i guess it's a postback issue.
I'm rather new to creating usercontrols and datatypes in .net for Umbraco so i'm sure i've overlooked something.
Any help is much appreciated!
(Umbraco v4.0.3)
Greets,
Harm
Sounds like it's not a large control, can you post the code behind and html source for your user control? Might save some of the back and forth questions.
-Chris
Hi guys!
Has anybody solved this problem ? I'm facing the same situation here.
Thanks
Sergio Nunes
I was having this same issue. After digging into it a bit I found that the Doc2Form.cs was calling the set method of my custom datatype and passing it a null value. This, of course, throws the dreaded 'Null Reference Exception' in the set method when using "value.ToString()'. However the error gets suppressed by a try/catch block. So it doesn't tell you what the error is. It just quits building the form.
Fortunatelyl, the fix for this is very easy. In the 'Set' method of any custom datatype, check the 'value' for null and set a default value if null is passed. Here's an example of my 'Value' property from my custom datatype.
I hope this helps anyone else out there having the same problem. If you find that it solves your problem please mark this post accordingly. Also a High Five would be much appreciated.
Happy coding fellow Umbracians.
is working on a reply...