Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

ParseToSelf not responding in custom property

Vote:
 
Hi, I have done a Custom Property and I want to save data in a specif way. This is how my class looks like: public class PropertyProfileTypes : PropertyString { private DropDownList m_ddlBusinesses; public override void CreateChildControls(string renderType, System.Web.UI.Control container) { // Render UI in /Edit mode. switch(renderType) { #region Edit case "edit": m_ddlBusinesses = new DropDownList(); container.Controls.Add(m_ddlBusinesses); container.Controls.Add(CreateParseValidator(m_ddlBusinesses)); #endregion break; default: base.CreateChildControls(renderType, container); break; } } public override void ParseToSelf(string str) { int kalle = 0; base.ParseToSelf(str); kalle++; this.Value = "kalle"; } } the CreateChildControls method is responding but not the ParseToSelf ?!?! It works perfectly in a .Net 1.1 but not in the above .Net 2.0 implementation. Is there something I´m missing? /Niklas Furberg
#13095
Jun 28, 2007 12:28
Vote:
 
Hi Niklas! When you say "not responding", do you mean literally _not responding_, i.e. that the process hangs and never returns from the ParseToSelf() method?? When you debug and step over the call to base.ParseToSelf(str), can you verify that it's this call that hangs? The posted code *shouldnt* behave like that, perjaps there is something else thats been left out? I assume that the 'kalle' variable is put in there in an effort to trace the execution path, but I'd really encourage you to use the VisualStudio debugger instead, its just so much more powerful! Regards, Johan Olofsson EPiServer AB
#15411
Jun 29, 2007 9:20
Vote:
 
Hi, aha, maybe I was a bit unclear. I have used debugging and placed a break point in the ParseToSelf method. But the break point is never hit and the code never executed, so I'm never able to modify the savedata. /Niklas
#15412
Jun 29, 2007 9:31
Vote:
 
Ah, ok, then I understand. The problem is that the m_ddlBusinesses is empty, so there's simply nothing to validate. If you add some ListItems to the dropdown, you do get called in ParseToSelf(). Like so: m_ddlBusinesses = new m_ddlBusinesses(); m_ddlBusinesses.Items.Add( new ListItem( "black" )); m_ddlBusinesses.Items.Add( new ListItem( "white" ) ); m_ddlBusinesses.Items.Add( new ListItem( "green" ) ); m_ddlBusinesses.Items.Add( new ListItem( "red" ) ); container.Controls.Add(m_ddlBusinesses); container.Controls.Add(CreateParseValidator(m_ddlBusinesses)); But, then you will encounter that the passed in string to ParseToSelf() will be null, as the base validator doesnt handle controls of type DropDownList(!) So, you will have to use a custom parse validator to handle this control, something like this: public override void CreateChildControls( string renderType, Control container ) { if("edit".Equals( renderType )) { m_ddlBusinesses= new DropDownList(); m_ddlBusinesses.Items.Add( new ListItem( "black" )); m_ddlBusinesses.Items.Add( new ListItem( "white" ) ); m_ddlBusinesses.Items.Add( new ListItem( "green" ) ); m_ddlBusinesses.Items.Add( new ListItem( "red" ) ); container.Controls.Add( m_ddlBusinesses); container.Controls.Add( CreateCustomParseValidator( new ServerValidateEventHandler(CustomParseValidator))); } else base.CreateChildControls( renderType, container ); } protected void CustomParseValidator( object sender, ServerValidateEventArgs ea ) { ea.IsValid = true; ParseToSelf(m_ddlBusinesses.SelectedValue); } public override void ParseToSelf( string str ) { base.ParseToSelf( str ); } Regards, Johan Olofsson EPiServer AB
#15413
Jun 29, 2007 10:04
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.