Problem with checkboxes

Posted by Community Admin on 03-Aug-2018 12:02

Problem with checkboxes

All Replies

Posted by Community Admin on 24-Jun-2012 00:00

I don´t know if this is the apropiate forum to post this. I´ve got a problem when I try to cacht the Selected state of checkboxes in a sitefinity form.

First of all, I must explain that I have use the form tool given by sitefinity, I have added to it my own asp.net controls, because I wanted to create dinamically checkboxes inside the checkboxList, so I had to remake the submit buttom. When I tried the controls in asp.net webform, it works but inside sitefinity the selected state was not taken, because first it loads the page then it does onClick submit buttom event. So when it go into onClick, the checkboxes don´t exists.

I have tried with javascript, making the checkboxes inside it and putting their result in a table, but the table disapear when you click the submit buttom.

What can I do to get the selected state? If there is no solution, which control should I use instead of checkboxList? Thanks

Posted by Community Admin on 24-Jun-2012 00:00

Hi Shil,

One way you capture form data from a SF FormsControl is to extend it with your own code.  To-do this you would override the FormsControl class.  Next you would modify the ConfigureSubmitButton method to add an additional click handler to the FormSubmitButton control.  In your event handler you can loop through the FieldControls collection and work with fields of type FormCheckboxes.  You can get then easily get Title and Value of that field and do anything you want with it.

You can download a sample project I wrote for this here: http://sdrv.ms/MHCf9q

Thomas

Posted by Community Admin on 25-Jun-2012 00:00

Thanks a lot, I have only a problem, I'm really a noob in sitefinity. I tried to learn by myself but I think there is still a long way to sitefinity knowledge. So I don't know how sitefinity works, I know asp.net, I know how to do a control, but I don't know about sitefinity clases (imports, namespaces etc.)

That class that you gave to me; Do I have to add one like that as sitefinity widget? Or does I have to import it to somewhere else?

I have tried to surf in sitefinity sdk but I can't get the knowledge I search for (I get lost there). I would like to know exactly hos sitefinity is inside itself.

Posted by Community Admin on 25-Jun-2012 00:00

Hi Shil,

You're very welcome.  With this project you would register this in the Settings area.  Here is a link to the documentation that explains how to-do this:

http://www.sitefinity.com/documentation/documentationarticles/adding-controls-to-the-toolbox 

For the sample I provided, you would register an assembly.  The project I provided produces a DLL that you either reference with your SF project or copy to your SF bin folder.  Then you register the control following the instructions above.  For the sample you would use "TomdDev.Sitefinity.Samles.CaptureForm, TomdDev.Sitefinity.Samles" as the CLR type.

After you register the control it will appear in your toolbox and you can add it to a page.

Thomas

Posted by Community Admin on 26-Jun-2012 00:00

I registrered tools first, I know how to do it, in fact I have registrered FormControls and PageControls. My problem is that I don't know Sitefinity clases and I can't find documentation about it. I know the sitefinity documentation you gave me but I think it is still imcomplete, so many times the answer are in blogs which I don't know how to find.

But apart from that I want to ask you if that control you gave me is put in PageControl or in FormControl, because I was searching for a FormControl but I have noticed that you write about PageControl. So, that control you gave me provider with a sitefinity form plus a submit button as we can see in the template that is open when we click in new Form inside sitefinity enviroment?

Posted by Community Admin on 26-Jun-2012 00:00

Hi Shil,

The control I provided is a Page Control.  You'll see an existing Form's Control in the Content section of the Page Controls toolbox.

One of the things you'll see is most .NET developers that get into customizing Sitefinity use a tool like JustDecompile.  As you start building modules and custom controls it is a valuable tool to understand how the internals of Sitefinity function and how to use the APIs to build custom solutions.

Thomas

Posted by Community Admin on 28-Jun-2012 00:00

Thanks a lot! I'm playing with that tool, it seems usefull! Now I can see what's inside sitefinity assemblies ^-^ I will tell you if I get doing the checkbox control.

This thread is closed