S
Sean
I am frustrated by the issue, and looking for a workaround.
I have a dropdown list, and a button and some other controls on the page.
When the button is clicked, I need to ensure a valid dropdown list item is
selected, (e.g. selectedIndex > 0, as the 1st item in ddl is dummy record).
Also, I need use some NET build-in validators for other controls.
What I did is:
- Create a JS function
function submitForm() {
if ( (document.getElementById("ddl").selectedIndex <= 0)) {
alert("nothing selected in ddl");
return false;
}
if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate();
if (Page_IsValid){
ValidatorOnSubmit();//this will fire postback
}
}
- on the server side add attributes to button.
btnSubmit.Attributes.add("onClick","submitForm()")
I wonder if anyone can help me out. Thanks.
I have a dropdown list, and a button and some other controls on the page.
When the button is clicked, I need to ensure a valid dropdown list item is
selected, (e.g. selectedIndex > 0, as the 1st item in ddl is dummy record).
Also, I need use some NET build-in validators for other controls.
What I did is:
- Create a JS function
function submitForm() {
if ( (document.getElementById("ddl").selectedIndex <= 0)) {
alert("nothing selected in ddl");
return false;
}
if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate();
if (Page_IsValid){
ValidatorOnSubmit();//this will fire postback
}
}
- on the server side add attributes to button.
btnSubmit.Attributes.add("onClick","submitForm()")
I wonder if anyone can help me out. Thanks.