Setting Default Value in an XHTML String

Vote:
 

Hi,

Is it possible to set a significant amount of text as the default value for an XHTML string.

There appears to be quite a short limit on the amount of text that can be entered as the default value, but ideally I would like to put a large amount of HTML in as a default value.

Can this be done?

Thanks,

Robert

#55430
Dec 01, 2011 17:55
Vote:
 

Hello,

You can set default values in the LoadedDefaultPageData event. In Global.asax or in an IInitializableModule listen to DataFactory.Instance.LoadedDefaultPageData += new PageEventHandler(this.SetValues);

private void SetValues(object sender, PageEventArgs e)
{
    e.Page["MyProp"] = "Value";
}

#55442
Dec 01, 2011 20:41
Vote:
 

Thanks for the reply Johan.

Does this mean the properties are automatically populated on the front end, or will this also apply in the editor environment.

For example, will this show default data in the text editor when the page is first created and in edit mode?

Robert

#55553
Dec 07, 2011 13:08
Vote:
 

Hi,

This is only for setting default values in edit mode. If you want a default value in a template you have do the logic yourself before rendering it:

<%= CurrentPage["MyString"] as string ?? "Default value" %>

    

#55554
Dec 07, 2011 13:20
Vote:
 

Great, it's only in edit mode that I want to do this.

So in the Global.asax would I put the PageEventHandler association in Application_Start?

Thanks again,

Robert

#55555
Dec 07, 2011 13:38
Vote:
 

Exactly. Or using an IInitializableModul, see this blog post.

#55556
Dec 07, 2011 13:46
Vote:
 

Brilliant, thanks!

Robert

#55560
Dec 07, 2011 15:00
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.