More in this section

Forums / Developing with Sitefinity / Using drop down control in the Products module

Using drop down control in the Products module

16 posts, 0 answered
  1. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    15 Nov 2008
    Link to this post
    Hi,

    I'm using the Products module sample in an ecommerce site that I'm building, and I've added a number of new meta fields.  Some of them would be better implemented as radio buttons or a drop-down list rather than a text box, but the persisted value would still be ShortText or perhaps Integer.

    Basically, I'm looking for a lightweight version of "Categories", where I don't really need to manage the values in the list of options.  For example, my products come in a case quantity of either 6 or 12.  So I really only need a radio button for a meta field called "CaseQuantity". 

    How would I do this? 

    My guess: 

    For the ControlPanelEdit.ascx, set up a private member called CaseQuantity and a metafield in web.config called CaseQuantity, then in CreateChildControls method, set the radio button control selected item to the value persisted in the metafield, and in the event handler for the radio button, set the private member to the selected value.  Or is there a better way?


    Thanks in advance!
    Mike
  2. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    16 Nov 2008
    Link to this post
    And along those same lines, if I did want to create something like Categories, and implement it in the Products Module, how would I go about that?  To be clear, I'm using Categories already; now I want to add "Countries" or something similar.  Obviously I can base my management control off the CategoriesManagement.ascx, but how do I persist the Countries?

    Thanks again,
    Mike
  3. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    17 Nov 2008
    Link to this post
    Hello Mike,

    The solution is to create a user control that wraps RadioButtonList control and implements ITextControl interface:
    1. Create a user control.
    2. D
    eclare
    RadioButtonList control on the user control.
    3. Implement ITextControl interface on the user control.
    4. Implement mandated Text property on the user control. In the get accessor return
    RadioButtonList.SelectedValue, in the set accessor set RadioButtonList.SelectedValue to the value.
    5. R
    egister your user control in the following templates:
        ~/Sitefinity/Admin/ControlTemplates/Products/ControlPanelEdit.ascx
       
    ~/Sitefinity/Admin/ControlTemplates/
    Products/ControlPanelInsert.ascx
    6. Replace the textbox with your user control.
    7.
    Set the ID of the user control to the meta key for which you wish to use it (in your case it is
    CaseQuantity)

    Regarding the question in your second post, you could use a new meta filed for storing the Country data as it is in Events module.

    Hope you will find the provided information helpful.

    Kind regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  4. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    17 Nov 2008
    Link to this post
    Oh man, that is so much easier than what I was trying to do all weekend! 

    I suppose I could use the same technique to store a product thumbnail in the database, only it would be a binary MetaField, right?  I think for now I'll just use the technique for thumbnails that's in the News module, but ultimately it would be nice to store the actual product images in the database, assuming that was supported. 

    Thanks a bunch--I owe you a real tall beer! 

    Actually, I thnk I owe everyone on your team a beer.  ;^)

    Regards,
    Mike
  5. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    18 Nov 2008
    Link to this post
    Hello Mike,

    I would suggest you use Images & Documents module to store the images in the database. In this case the Thumbnail meta field should be of type ShortText or LongText (as it is in News module) and you need just to select its value from Libraries and not from the file system.

    Do let us know if you need any further assistance.

    All the best,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  6. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    18 Nov 2008
    Link to this post
    I see I still have a lot to learn about Sitefinity!  That should work well for my current project.  Although, I have a similar requirement in an upcoming project that would be better to store the image in the page itself.  It's kind of like a profile page for a user, so I don't want them to select from a large library of images, but rather manage one single image associated with their page.

    I think I saw a blog from Ivan on this...A web 2.0 example for SF using a dating site that describes many of the same requirements.  I guess I'll cross that bridge later.


    Mike
  7. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    19 Nov 2008
    Link to this post
    Hi Pepi,

    I'm trying to implement the Thumbnail picker from the News Module, but I'm having difficulties with the picker dialog box.  All the links in the box, with the exception of the page 1|2 link, fail to work.  They're trying to do a webform_dopostback, rather than a simple _dopostback.  The page links do it correctly.

    For example, in the News module, the cancel button uses this link:

    javascript:__doPostBack('ctl00$ContentPlaceHolder1$contolPanel$ctl00$ctl00$editMetaFields$ctl01$ctl00$cancelButton','')

    whereas when I add it in the products module, the cancel button uses this link:

    javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$contolPanel$ctl00$ctl00$editMetaFields$ctl01$ctl00$cancelButton", "", true, "", "", false, true))

    I've run in to this before when I was building a custom type editor, but in that case I had control of the popup dialog.  What could be causing this? 

    Also, I can't figure out how to select images from the library rather than the filesystem, The News module example uses the filesystem:

    CommandArgument="Thumbnail:Telerik.FileManager.UrlWebEditor, Telerik.FileManager"

    What's the namespace for using the library?

    Thanks!
    Mike Sharp
  8. Joe
    Joe avatar
    138 posts
    Registered:
    24 Sep 2012
    19 Nov 2008
    Link to this post
    Hello Mike,

    Thanks for contacting us.

    We are using a special compiled control that will pull the images from that module, so there is no need to set the command name property. Here is the article for more info. After you add it, add the image control to the page that has the module.

    As a side note, I noticed you are doing lots of work with adding meta fields. If the component, such as an image, does not implement the ITextControl interface, then you just cannot give the control's ID the same name as the meta field to bind it. To solve this issue, we have a meta master tool that would assist you.

    Please let us know if you need further assistance.

    Best wishes,
    Joe
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    19 Nov 2008
    Link to this post

    Thanks, Joe,

    That works well, and solves the problem with the webform__DoPostBack in that dialog.  Though I'm still wondering why that happens.  Any ideas?

    Also, thanks for your suggestion on the MetaMaster tool.   I found that article after I'd already implemented some basic controls such as drop-down lists and radio buttons using the ITextControl interface.  I like it because I can easily get my values for the dropdown list from another data source, or just hand edit them.  

    I was having trouble figuring out how to do this with an integer, and found the MetaMaster tool.  I haven't tried implementing it yet, but am looking forward to trying it out as it's critical for my next project to embed the image directly into the content item for the page (rather than store it in the library).  I'm hoping I can make this work! ;^)

    Regards,

    Mike Sharp

  10. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    25 Nov 2008
    Link to this post
    Hi Mike,

    The expressions:
    • javascript:__doPostBack
    • javascript:WebForm_DoPostBackWithOptions
    are two different ways of submitting the form. Asp.Net generates this in regards to what type of control is submitting the form. If for example you submit the form through submit button, javascript:__doPostBack should be rendered. But, if you submit the form through other control which requires javascript itself to do it, then the rendered script is with "options". If you submit the form through a link, you should use javascript, right? I guess that some of the dialogs was not using a standard submit button, therefore you got the DoPostBackWithOptions script rendered.

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  11. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    25 Nov 2008
    Link to this post

    Hi Georgi,

    Thanks for your response.  I think I understand the difference between the two types of postback, but I was following a link that's built by your compiled control, so I can't do a whole lot about it (at least I think that part is compiled).  I was wondering why a control that uses the simple DoPostBack in the News Module tries to validate using the WebForm__DoPostBack when I put the control in the Products Module.  My assumption is that something in the compiled code changes the CausesValidation state of the linkbutton.

    In fact, I still have problems with the Command Panel in the Products module.  If you click the link to Create a new item, and then when the form opens, click the Products link in the Command panel, you'll see the form uses the WebForm__DoPostBack which attempts to validate (and fails because you have blank required fields).   The command panel linkbuttons should all be set to CausesValidation="false".  

    I haven't looked at the Products module CommandPanel closely yet to see how to fix this, but Tags and Categories work fine.  It's the other links in the Command Panel that have this problem.

    The Cancel button on the ControlPanelInsert.ascx also had the trouble, if I recall correctly.  But I fixed it there.

    Regards,
    Mike Sharp
  12. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    28 Nov 2008
    Link to this post
    Hello Mike,

    Could you elaborate on why do you hardcode your links directly with javascript:__<something>? You can turn off the validation on every button whenever its link is inactive (it is inactive because there are validators instead). Perhaps we are missing something.

    Greetings,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  13. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    29 Nov 2008
    Link to this post

    I'm not  hardcoding anything...I'm just using the products module as supplied.  I've customized some aspects of the control panel, like sorting the metafields, and a few specialized controls.  But I haven't made any changes to the command panel. 

    If you re-read my last post, keeping in mind I've made no changes here at all, I think you'll see what I'm saying.

    Thanks,

    Mike

     

  14. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    16 Dec 2008
    Link to this post
    Hi Mike,

    To fix the issue described in the post before the last one, follow the instructions below:
    1. Open \Sitefinity\Admin\ControlTemplates\Products\CommandPanel.ascx file
    2. Find the control with ID="contentViewButton" and set its CausesValidation property to false:

    <asp:LinkButton ID="contentViewButton" Text="<%$Resources:ProductItems %>" runat="server" CausesValidation="false" /> 

    Hope this helps.

    Greetings,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  15. Mike
    Mike avatar
    208 posts
    Registered:
    10 Dec 2007
    16 Dec 2008
    Link to this post
    Yes, that fixed it!  Thanks Pepi.  I'm not sure why I didn't see that myself...I thought I'd checked that control template.  For what it's worth, in case you folks are continuing development on the products module, there are a number of the linkbuttons that are missing the CausesValidation="false" attribute.

    I'm integrating the products module with CommerceFinity, and things are going fairly well.  I'll post my results on the forum when I'm done, in case others try it themselves--hopefully the site will be live in the next couple weeks.  But I'm very happy with what the products module brings to the table when it comes to browsing/cross selling products.  It's much more flexible than any shopping cart, and provides a unique user experience.

    Thanks again for all your help!
    Mike Sharp
  16. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    17 Dec 2008
    Link to this post
    Hello Mike,

    We are happy to hear that you have managed to solve the issue. Definitely, we will take into consideration your suggestion about the buttons which should not cause validation.
    Now, we are closing this thread. Please, feel free to open it when you are done with the integration.

    Kind regards,
    Pepi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Register for webinar
16 posts, 0 answered