Current filter:
                                You should refresh the page.
                                Support Center
                                0
                                  • Hi,

                                    I have a problem with setting the initial value in the combo box for which validation should not pass this value. E.g the combobox has (Please Select) as initial value, and the user can choose whichever countries he/she wants. Validation should not allow (Please Select) to go through and prompt the user to select a country.

                                    This feature was in the original .net controls, but it is not in devexpress's control to set the initial value. Is there a way through it?
                                    Thanks.

                                    Jackson

                                • Vest (DevExpress Support) 05.24.2011

                                  Hello Jackson,

                                  Thank you for the scenario description. I think that it would be better to create the first item with the Nothing (NULL) value, and then enable the IsRequired validation for the control. If a user does not select other items, the control will try to pass the Nothing value to the server side. Due to validation, this attempt will be canceled.

                                  Please try this approach and let me know if it suits you better.

                                  If I am incorrect in my solution, please clarify your task, so I can give you a better approach.

                                  Thanks,
                                  Vest

                                • Jackson Ong 05.24.2011

                                  Hi Vest,

                                  I think i wasnt really clear on what the issue is about. In the original .net RequiredFieldValidator, there is a property call initial value. Where you can set it as the initial value and the validator will not assume it as valid value. My question is how do you set this property in devexpress's control?

                                  I am putting a small piece of code here. Do copy and run it. Click the button and you will know what i mean.

                                      <div>
                                          <dx:ASPxComboBox ID="ASPxComboBox1" runat="server" ClientIDMode="AutoID" SelectedIndex="0"
                                              ValueType="System.String">
                                              <Items>
                                                  <dx:ListEditItem Text="(Please Select)" Value="0" />
                                                  <dx:ListEditItem Text="Singapore" Value="1" />
                                                  <dx:ListEditItem Text="Malaysia" Value="2" />
                                              </Items>
                                              <ValidationSettings ValidationGroup="MST">
                                                  <RequiredField ErrorText="This is a required field" IsRequired="True" />
                                              </ValidationSettings>
                                          </dx:ASPxComboBox>
                                          <br />
                                      </div>
                                      <asp:DropDownList ID="DropDownList1" runat="server" ValidationGroup="MST">
                                          <asp:ListItem Selected="True" Value="(Please Select)">(Please Select)</asp:ListItem>
                                          <asp:ListItem Value="1">Singapore</asp:ListItem>
                                          <asp:ListItem Value="2">Malaysia</asp:ListItem>
                                      </asp:DropDownList>
                                      <br />
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="DropDownList1"
                                          ErrorMessage="This is a required field" InitialValue="(Please Select)" ValidationGroup="MST"></asp:RequiredFieldValidator>
                                      <br />
                                      <br />
                                      <asp:TextBox ID="TextBox1" runat="server" Text="(Please Select)"></asp:TextBox>
                                      <br />
                                      <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="TextBox1"
                                          ErrorMessage="This is a required field" InitialValue="(Please Select)" ValidationGroup="MST"></asp:RequiredFieldValidator>
                                      <br />
                                      <asp:Button ID="Button1" runat="server" Text="Button" ValidationGroup="MST" />

                                You must  log in  or  register  to leave comments

                                1 Solution

                                0

                                Hello Jackson,

                                Thank you for your clarification.

                                ASPxComboBox does not have such a property. We have the ASPxComboBox - Support NullText for DropDown Mode suggestion about this functionality. Please track this to be notified about our progress. We can offer you a workaround. It is possible to add the required item to the ASPxComboBox and apply a custom validation rule to it. To realize this, set the ValidationSettings.EnableCustomValidation property to true, and handle the ASPxClientEdit.Validation event. Apply the required validation rules. Call the ASPxClientEdit.ValidateGroup in the standard Button ClientClick event handler, because standard buttons do force ASPxEditors validation.

                                You also can use the ASPxButton to more easily validate our controls. By default, page validation is performed when an ASPxButton control is clicked.

                                Attached is a sample.

                                Please let us know whether or not this approach suits your needs. If you need any further help on this subject, please feel free to reactivate this ticket.

                                Thanks,
                                Jenny

                                • Jackson Ong 05.27.2011

                                  Hi Jenny,

                                  Thanks for the suggestion. I have use a javascript to clear the text when the text is the initial value and validation will work, but I thought that might be a more straight forward solution to it.
                                  Thanks for your help.

                                  Jackson

                                • Jenny (DevExpress Support) 05.29.2011

                                  Hello Jackson,

                                  We cannot offer you a more straight forward solution because ASPxComboBox doesn't have the required functionality yet.

                                  If you need any further assistance on this subject, please feel free to reactivate this ticket.

                                  Thanks,
                                  Jenny

                                • mario pastilha 02.15.2013

                                  Hi, is above still the only solution available?

                                  I tried below but it Does NOT display in the combobox

                                  edtSettings.Properties.NullDisplayText = "Select One";

                                • Hello Mario,

                                  I have extracted your comment to a separate ticket created on your behalf to process your inquiry more effectively
                                  Q24926 - ASPxComboBox NullText

                                You must  log in  or  register  to leave comments

                                If you need additional product information, write to us at info@devexpress.com or call us at +1 (818) 844-3383

                                FOLLOW US

                                DevExpress engineers feature-complete Presentation Controls, IDE Productivity Tools, Business Application Frameworks, and Reporting Systems for Visual Studio, along with high-performance HTML JS Mobile Frameworks for developers targeting iOS, Android and Windows Phone. Whether using WPF, Silverlight, ASP.NET, WinForms, HTML5 or Windows 8, DevExpress tools help you build and deliver your best in the shortest time possible.

                                Copyright © 1998-2014 Developer Express Inc.
                                All trademarks or registered trademarks are property of their respective owners