November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
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