November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
To create a textbox you can use this code
[Serializable]
[PageDefinitionTypePlugIn()]
public class PropertyXhtmlBox : EPiServer.SpecializedProperties.PropertyXhtmlString
{
public override EPiServer.Core.IPropertyControl CreatePropertyControl()
{
return new PropertyXhtmlBoxControl();
}
}
public class PropertyXhtmlBoxControl : PropertyLongStringControl
{
public override EPiServer.Core.TableRowLayout RowLayout
{
get
{
return TableRowLayout.Default;
}
}
public override void CreateEditControls()
{
this.EditControl = this.CreateTextBox();
this.EditControl.ID = base.Name;
base.CopyWebAttributes(this.EditControl);
EditControl.CssClass = "";
this.Controls.Add(this.EditControl);
this.SetupEditControls();
}
protected override TextBox CreateTextBox()
{
TextBox box = new TextBox();
box.Width = Unit.Pixel(400);
box.Height = Unit.Pixel(100);
box.CssClass = "";
box.Text = this.ToString();
box.TextMode = TextBoxMode.MultiLine;
return box;
}
}
The default value will only be triggered on new pages, and can be set in admin mode for the property
Thank you Anders!
About the the default value, i want to read strings from a database and fill my textbox. Can that be done?
It can be done, its possble to override the GetDefaultValue method on the PropertyData class
Thanks again Anders, you've been very helpful! Just one more question...
If i, instead of a normal textbox, wants to show the strings with the possibility to remove a marked string without saving the entire page. Is that also possible?
I will certainly try :)
What the customer want is when going to editmode, they want a textbox or listbox populated with a list of string that i get from a database based on a id on the current page.
Now they want a remove button next to the textbox to be able to delete a selected string in the textbox from the database in editmode without having to save and publish the page. Does this make sense?
Another question about the GetDefaultValue method, in order to get the data from the database i need to reach a property (id) on the current page that the custom propery is attached to. In my PropertyXhtmlBoxControl class i have the currentpage but not in the PropertyXhtmlBox class. How can i get to the currentpage in the control class?
It sounds like that you want the values in the database to be the correct, and the value stored on the pages shouldnt matter.
you can access the database from the CreateEditControls
The id of the pages can be found by using this.Properties["PageLink"] from the Control class
If I where you I would have saved the new values to the database when a page is published. Hook up on the event PublishedPage
That worked fine!
I can access the database in CreateEditControl but how do i get the output to the SetDefaultValue method in the other class?