Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Girish Khadse 52 posts 132 karma points
    Jun 07, 2013 @ 07:14
    Girish Khadse
    0

    How to put an validation for selected value of dropdown datatype.

    Hi All..

     I am using custom dropdown datatype for countries as a member property. I want to make it compulsory. And also I want to insert one option of "Choose" in dropdown. And while saving I want to choose if the country was selected. I have used ASP.Net user control to created custom datatype for dropdown. Can anyone guide how I should validate the selected value is Country?

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Jun 07, 2013 @ 07:55
    Dave Woestenborghs
    0

    Maybe you can use this datatype and don't need to create it your self : http://our.umbraco.org/projects/backoffice-extensions/country-picker-property-editor

     

  • Girish Khadse 52 posts 132 karma points
    Jun 07, 2013 @ 10:48
    Girish Khadse
    0

    Thanks @dawoe. It looks to be an good option. But in my case, I have currency dropdown also. And might get some more dropdowns in future. So is there any other way to put validation?

  • Charles Afford 1163 posts 1709 karma points
    Jun 08, 2013 @ 20:36
    Charles Afford
    0

    Are you using any compiled code?  You would probably want a model  with your drop down as a property and then have a custom validation attribute on the property.  Charlie :)

  • Girish Khadse 52 posts 132 karma points
    Jun 10, 2013 @ 05:48
    Girish Khadse
    0

    Hi Charles..
    I am using ASP.Net user control for fetching ucommerce currency and countries. Then I use this user controls for creating custom datatypes for currency and countries. I think, by using ASP.Net user control I cant use the Model and Valiation attribute approach. Or would you please more elaborate on it?

     

  • Girish Khadse 52 posts 132 karma points
    Jun 11, 2013 @ 10:55
    Girish Khadse
    0

    Charles.. I am still not able to resolve the issue. Any one has any idea how I can move ahead?

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Jun 11, 2013 @ 11:05
    Dave Woestenborghs
    100

    You can mark the property to be required on you doctype.

  • Girish Khadse 52 posts 132 karma points
    Jun 11, 2013 @ 11:12
    Girish Khadse
    0

    Dawoe.. I have an custom datatype for countries and currencies. Ucommerce countries and currencies are fetched using user controls. With the countries and currencies, we want to insert one more option Saying "Choose" which will be selected at first. We are using this datatype for member types. And also we want to enforce validation that country/currency is selected. That mean somehow I want to check if I have selected choose option, And I can show validation message. So far I dont see docType envolved in this scenario :( 

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Jun 11, 2013 @ 11:14
    Dave Woestenborghs
    0

    I meant membertype. So if you dropdown option "Choose" has a empty value. You can mark the property to be mandatory on your membertype.

  • Girish Khadse 52 posts 132 karma points
    Jun 11, 2013 @ 11:48
    Girish Khadse
    0

    I have set the property as mandatory . And also value for "Choose" is kept empty (havenot added value, or did you mean blank - "") . But it is not working. Following is the syntax I add the "Choose" option to dropdown  : 

    ddlCountries.Items.Insert(0, new ListItem() { Text="Choose"});  // value not added

    Should I use regex ?

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Jun 11, 2013 @ 12:00
    Dave Woestenborghs
    0

    You should also set the value for your choose item. If not set the Text property will be used for the value.

  • Girish Khadse 52 posts 132 karma points
    Jun 11, 2013 @ 12:20
    Girish Khadse
    0

    Yup.. Setting Value = "" solved the issue. Thank you :)

Please Sign in or register to post replies

Write your reply to:

Draft