What am I not understanding about the fluent api?
Hi guys,
I have set up a widget for the backend of my Sitefinity site that has three textboxes and a button. The goal is to create a new column in the database:
protected void btnAddClick(object sender, EventArgs e)
Type TelerikType = Type.GetType(txtTelType.Text);
Type ColumnType = Type.GetType(txtColType.Text);
string error = "";
if (TelerikType == null)
error = "Telerik Type is invalid";
if (ColumnType == null)
error = "Column Type is invalid";
if (error.Length == 0)
App.WorkWith()
.DynamicData()
.Type(TelerikType)
.Field()
.TryCreateNew(txtName.Text, ColumnType)
.SaveChanges(true);
error = "Added column successfully";
txtColType.Text = txtName.Text = txtTelType.Text = "";
literalErrorText.Text = string.Format(literalErrorText.Text, error);
I am having two problems:
When I enter Telerik.Sitefinity.Pages.Model.PageNode into the textbox, Type.GetType(txtTelType.Text) is returning null.
If I replace that portion with typeof(PageNode) I get "Specified type 'Telerik.Sitefinity.Pages.Model.PageNode' is not a dynamic type."
I'm hoping somebody might have some insight as to why these things wouldn't work correctly, or possibly a better way to approach this issue? For reference, my goal (at least for now) is to add a dynamic column that references PageNode so that I can specify a ShowInLeftNavigation boolean and a ShowInRightNavigation boolean. Thank you for any help you can provide.
I figured out what I was doing wrong with the TelerikType, I needed to qualify it with an assembly name, so I changed it thusly:
var assembly = typeof(Telerik.Sitefinity.News.Model.NewsItem).Assembly; Type TelerikType = Type.GetType(txtTelType.Text + ", " + assembly.ToString()); I would still appreciate a better approach if anybody has any ideas, and I would still appreciate help on the second question, which is to say, why isn't pagenode dynamic? Where do I add a column to pages, and how do I access it after I do that? I'm sorry if this is clear in the documentation, I can't seem to find the right information in there.
I guess what I'm really after here is why is PageNode not a dynamic type, and what dynamic type should I use here to attach a column to pages.
Hi Jeff,
The type you need to use is PageData, not PageNode. Can you check the following thread, that describes the same problem and provides solution:
http://www.sitefinity.com/devnet/forums/sitefinity-4-x/bugs-issues/custom-fields-for-pages.aspx
If you have any further questions, please do not hesitate to write back.