CodeCharge Studio | All ASP PHP Perl ColdFusion Java C#.NET VB.NET |
This example shows how to dynamically set a default value for a control. In this case, we have a Listbox called MonthBox which is located in a Record form called Registration. The event code checks for an input parameter called MonthBox and if the input parameter is not available, the Listbox value is set to the current month.
Function Registration_MonthBox_BeforeShow(Sender) If IsEmpty(CCGetParam("MonthBox",Empty)) Then Registration.MonthBox.Value = Month(NOW()) End if End Function
function Registration_MonthBox_BeforeShow(& $sender) { global $Registration; if (CCGetParam("MonthBox","") == "") { $Registration->MonthBox->SetValue(date("n")); } }
sub Registration_MonthBox_BeforeShow() { $mon = (localtime())[4]; if (CCGetParam("MonthBox","") eq "") { $Registration->{MonthBox}->{Value} = $mon+1; } }
<!---Registration_MonthBox_BeforeShow ---> <CFMODULE Template="CCGetParam.cfm" strName="MonthBox"> <CFIF CCGetParam EQ ""> <CFSET fldMonthBox=DateFormat(Now(),"m")> </CFIF>
'Registration_MonthBox_BeforeShow If IsNothing(Request.QueryString("MonthBox")) Or Request.QueryString("MonthBox") = "" Then RegistrationMonthBox.Value = Month(NOW()) End if
//Registration_MonthBox_BeforeShow if (Request.QueryString["MonthBox"] == null || Request.QueryString["MonthBox"].Length == 0) { RegistrationMonthBox.Value = DateTime.Now.Month.ToString(); }
//Registration_MonthBox_BeforeShow if (StringUtils.isEmpty(e.getPage().getParameter("MonthBox"))) { e.getControl().setValue(new java.text.SimpleDateFormat("M").format(new Date())); }