This is a migrated thread and some comments may be shown as answers.

Issues With asp Validation Controls

2 Answers 57 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Abdallah
Top achievements
Rank 1
Abdallah asked on 05 Feb 2011, 07:19 AM
Dear all,

1-Please i used a asp required validation controls with radcombo box and the InitialValue property of required validation not working .
2-other controls is working only in the first view of the page if the page is posted back the validation not working ..
Please help me in this .
 
Best Regards 

2 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 07 Feb 2011, 03:01 PM
Hello Abdallah,

I would suggest using a CustomValidator and writing the javascript to validate the control. Like so:

ASP.NET:
<asp:CustomValidator ID="CustomValidator1" runat="server" Display="Dynamic" ValidationGroup="Save"
                    ClientValidationFunction="ValidateRadComboBox">*<asp:CustomValidator>

JavaScript:
function ValidateRadComboBox(source, args){
    var combo = $find("RadComboBox1.ClientID");
      
    args.IsValid = combo.get_selectedIndex() > 0;
}

That's pretty much it. You'll need to handle the server-side check for the CustomValidator by handling the OnServerValidate event.

I hope that helps.
0
Thad
Top achievements
Rank 2
answered on 08 Feb 2011, 06:14 PM
Hey Abdallah,

One thing that got me for a bit was that the RequiredFieldValidator works on the TEXT property of a RadComboBox, not on the Value property like a normal DropDownList.

It might be that you just need to change the InitialValue to something that represents the textual value of the default item.

Hope that helps,
Thad
Tags
ComboBox
Asked by
Abdallah
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
Thad
Top achievements
Rank 2
Share this question
or