CodeCharge Studio
search Register Login  

Web Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Initial Value for Search form CheckBox

Print topic Send  topic

Author Message
Paul Shearing
Posted: 12/04/2005, 10:19 AM

I need a checkbox on a search form to be displayed with an initial value of Checked=True. I have tried the following:

1) In design mode set the Default Value to Checked
2) In design mode changed Control Source Type to [Code Expression]
3) In the code, modified the constructor code to have a non-zero initial value. According to the code for CCCreateControl (in Classes.ASP) this should set the initial state for the newly-created control to .State = True. The code in Private Sub Class_Initialize() now looks like this:

Set s_vesselACTIVE = CCCreateControl(ccsCheckBox, "s_vesselACTIVE", Empty, ccsBoolean, DefaultBooleanFormat, 1)

4) Immediately followed the code above with an explicit setting of the value: s_vesselACTIVE.State = True

5) Placed the same line (s_vesselACTIVE.State = True) as the last executable statement in the subroutine Sub Show(tpl)

None of these have worked. What am I doing wrong?

Kind regards

Paul
peterr


Posts: 5971
Posted: 12/04/2005, 12:42 PM

Paul,
Your methods 3-5 are not recommended as this may lock you out of being able to make changes to your page design. All our tutorials, solutions and examples show how to use events and this is the recommended method for changing control values.
So in your case you can use either #1, or the Before Show event of the form or control to assign a value to that control.
First please check what Boolean Format is specified in your Connection->Server. It should match the format used by your database, and one of the two valid values should be assigned to the checkbox.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Paul Shearing
Posted: 12/04/2005, 2:20 PM

Thanks Peter

I have reversed the edits to the code for points 3) .. 5).

My boolean format is 1;0 (SQL 2000). In design mode I have set the properties of the check box thus:

Name: s_vesselACTIVE
Visible: Yes
Control Source Type: Database Column
Control Source:
Data Type: Boolean
Checked Value: 1
Unchecked Value: 0
Default Value: Checked
Error Control:
Validation Rule:
Validation Text:

That doesn't work. So I have created a [Before Show] event for the control in which I have placed the following single line of code:

WEB_FLEET_SEARCHSearch.s_vesselACTIVE.State = 1

That doesn't work either. I have tried, just for good measure:

WEB_FLEET_SEARCHSearch.s_vesselACTIVE.State = ccsChecked

WEB_FLEET_SEARCHSearch.s_vesselACTIVE.State = "1"

and
WEB_FLEET_SEARCHSearch.s_vesselACTIVE.Value = 1

The HTML for this control is:

<input type="checkbox" value="1" name="{s_vesselACTIVE_Name}" style="font-weight: 700">

Yet the control remains stoically unset when the form is loaded.

I'm plumb outa ideas

Kind regards

Paul
peterr


Posts: 5971
Posted: 12/04/2005, 3:05 PM

I just tested every possible combination with CCS 3.0.1.5 and ASP, and it works every time for me. I tried Default Value=Checked, plus all the following events:
FormName.CheckBoxName.State=False
FormName.CheckBoxName.State=True
FormName.CheckBoxName.State=0
FormName.CheckBoxName.State=1
FormName.CheckBoxName.Value=False
FormName.CheckBoxName.Value=True
FormName.CheckBoxName.Value=0
FormName.CheckBoxName.Value=1

Couldn't find any problem with any of them and the default value is always checked or unchecked correctly.

I suspect that maybe you already made some changes to the generated code and therefore locked the code so it cannot be regenerated anymore?
Possibly you can try changing the checkbox to a textbox just to see if the page will be regenerated correctly and the change will take effect. Maybe you can also try creating another test page. Don't know what else to tell you since I've never seen such problem before.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
Paul Shearing
Posted: 12/04/2005, 3:55 PM

Thanks Peter

I tried your suggestion of converting to a text box, publishing, and then converting the field back to a checkbox and it now works as expected.

Thanks. I would never have thought of doing that.

Paul

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

PHP Reports

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.