Ask a Question related to ASP.NET General, Design and Development.
-
Sean #1
JS validation doesnt work when NET build-in validators are used
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.
Sean Guest
-
Validators and Page validation
My page is not receiving any validators that I have added to the page during PageIndexChanged event. If I call the same piece of code from some... -
postback doesn't work with validators.!
I have a strange problem.. once I put any validators on my form, say a simple RequiredFieldValidator, then there is no postback happening. Even... -
test and masking movements ok in build mode in fla doesnt work
This use to work on flash 6, but in mx 2004 trial. it doesnt does it work in real 2004 ? Also how is using apple for flash different from pc, going... -
#25955 [Opn]: MacOS 10.3 (Panther) doesnt build php. Fails on resolver stuff
ID: 25955 User updated by: andreas at fink dot org Reported By: andreas at fink dot org Status: Open Bug Type: ... -
validation summary doesnt display when there's client-side validation
I have a custom validator that validates a numeric field, txtField, that allows for thousand separators. I also placed a validation summary so... -
S. Justin Gengo #2
Re: JS validation doesnt work when NET build-in validators are used
Sean,
Use the required field validator instead of the javascript you wrote. The
required field validator has a property, "InitialValue", set that property
equal to the initial text in your dropdown and that will solve your problem.
Sincerely,
--
S. Justin Gengo, MCP
Web Developer
Free code library at:
[url]www.aboutfortunate.com[/url]
"Out of chaos comes order."
Nietzche
"Sean" <ssmith@yahoo.com> wrote in message
news:eoWy$t3WDHA.384@TK2MSFTNGP12.phx.gbl...record).> 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> 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.
>
>
>
>
>
S. Justin Gengo Guest
-
Ken Cox [Microsoft MVP] #3
Re: JS validation doesnt work when NET build-in validators are used
There's a detailed discussion by Mike Moore on this issue:
[url]http://www.aspalliance.com/kenc/faq6.aspx[/url]
"Sean" <ssmith@yahoo.com> wrote in message
news:eoWy$t3WDHA.384@TK2MSFTNGP12.phx.gbl...
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.
Ken Cox [Microsoft MVP] Guest



Reply With Quote

