|
|
|
|
| |
|
Setting default values for BizForm
|
|
This article explains how you can set default values for BizForm when it is displayed on the site using BizForm web part.
|
|
Applies to:
|
Kentico CMS 2.0 and later
|
|
For setting default values for BizForm you will need to change code-behind of the BizForm web part. It is therefore recommended to create copy of existing BizForm web part first (please see http://www.kentico.com/docs/devguide/modifying_the_design_of_standa.htm for more details), modify it, and then use this copy instead of original BizForm web part.
Once you have the BizForm web part copied, you can change the OnContentLoaded() method as following:
/// <summary>
/// Content loaded event handler
/// </summary>
public override void OnContentLoaded()
{
base.OnContentLoaded();
SetupControl();
Control ctrl = BizFormNew.BasicForm.FindControl("FirstName");
//You should specify 'Column name' attribute from 'CMSDesk -> Tools -> Biz form -> Edit appropriate BizForm -> Fields -> select appropriate field' as parameter for FindControl method.
if ((ctrl != null) && (ctrl is TextBox))
{
if ((Request.QueryString["FirstName"] != null) && (Request.QueryString["FirstName"] != ""))
{
((TextBox)ctrl).Text = Request.QueryString["FirstName"];
}
}
}
This sample code checks the query string for FirstName parameter. If this parameter is presented it sets its value into specified field when the BizForm is loaded on the page. In the example there is TextBox control used, but you can use other appropriate controls like Label, DropDown list, etc., depending on the type of the field, as well.
|
|
See also:
|
|
|
|
|
| |
|
|
|
| |
|
|
| |
Technical Support
If you do not find an answer to your questions here, please contact our technical support at support@kentico.com. |
|
| |
|
|
|
|
|
|
|