469,628 Members | 1,192 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,628 developers. It's quick & easy.

Client Validation Javascript not rendering

Hi,
I have run into a very strange scenario. In developing an ASP.NET
application on framework version 1.1, I found that certain client-side
validation scripts were not being rendered. The reason we came up with for
this was because we had a PageBase base class for all our pages. This base
class takes the controls on the child page class and places them onto the
form being rendered. It seems that in this process, the rendering of the
validation calls gets lost. To overcome this problem I added code to add the
required client-side function call on the "onclick" event of the necessary
buttons as follows:

<input type="submit" name="btnSave" value="Save" onclick="btnClose.enabled =
'false';if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate();
if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); "
language="javascript" id="btnSave" class="button" style="width:68px;" />

Can anybody tell me if the original problem was a bug in the framework, IIS5
etc.? Also, if it was a framework bug, why does it differ with the same
version on WinXP Pro and Win2003 Server?

Any light on this subject will be greatly appreciated.

Fourge
btnSubmit.Attributes.Add("onclick","btnClose.enabl ed = 'false';if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ");

After adding this, it worked great in our development and test environment.
Our development is done on Windows XP Pro with IIS5 and our testing on
Windows 2000 Server with IIS5. Both environments running .NET Framework 1.1.

One of the deployments we did was into the Windows 2003 Server environment.
Once th application was running in that environment, we found that the
validation function calls above were now being added and so we were getting
the javascript calls twice in the rendered html page as follows:
Nov 19 '05 #1
2 1919
While there is a bug in client-side validation in ASP.NET 1.1 SP1, I don't
think it is involved here. That bug prevents the button click from ever
submitting the page. See
http://www.asp.net/Forums/ShowPost.a...&PostID=739537

If the button is not generating its onclick event code, there are two
possible reasons:
1. CausesValidation is false on the button.
2. The Page.Validators collection has no validators (or perhaps just
"active" validators where their Visible property is true.)

I don't know how your code moves controls around and wonder if it ends up
clobbering the Page.Validators collection.

--- Peter Blum
www.PeterBlum.com
Email: PL****@PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fourge" <fo*********@online.nospam> wrote in message
news:19**********************************@microsof t.com...
Hi,
I have run into a very strange scenario. In developing an ASP.NET
application on framework version 1.1, I found that certain client-side
validation scripts were not being rendered. The reason we came up with
for
this was because we had a PageBase base class for all our pages. This
base
class takes the controls on the child page class and places them onto the
form being rendered. It seems that in this process, the rendering of the
validation calls gets lost. To overcome this problem I added code to add
the
required client-side function call on the "onclick" event of the necessary
buttons as follows:

<input type="submit" name="btnSave" value="Save" onclick="btnClose.enabled
=
'false';if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate();
if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); "
language="javascript" id="btnSave" class="button" style="width:68px;" />

Can anybody tell me if the original problem was a bug in the framework,
IIS5
etc.? Also, if it was a framework bug, why does it differ with the same
version on WinXP Pro and Win2003 Server?

Any light on this subject will be greatly appreciated.

Fourge
btnSubmit.Attributes.Add("onclick","btnClose.enabl ed = 'false';if
(typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); ");

After adding this, it worked great in our development and test
environment.
Our development is done on Windows XP Pro with IIS5 and our testing on
Windows 2000 Server with IIS5. Both environments running .NET Framework
1.1.

One of the deployments we did was into the Windows 2003 Server
environment.
Once th application was running in that environment, we found that the
validation function calls above were now being added and so we were
getting
the javascript calls twice in the rendered html page as follows:

Nov 19 '05 #2
Hi Fourge,

I'm also a bit interested in how your base pages adding those validation
controls. As far as I knew, the validation control will regsiter the
clientside script in their OnPrender event. So if we adding the validtion
controls correctly before Prerender, that should not be the problem.

I think we can first check whether the output page is correctly emiting the
validation's required script in page output and whether the script files on
the deployment server is correctly installed. As you mentioned that when
you're using the base page to adding those validation controls and the
validtion not work, have you tried viewing the page's output html code at
the clientside (via View source). You can have a look whether the script
codes are embeded correctly. If the code is correctly there, we may have a
check on the server's asp.net clientside script installation. Try
executing the
aspnet_regiis -c
command to reinstall the asp.net common script files on the server and test
again to see whether it works.

Anyway, I think it'll be better to start test from a simple page with a
textbox and a validtion control.

If there is any other findings, please feel free to post here. Thanks.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by rmgalante | last post: by
5 posts views Thread by Sun Jian | last post: by
4 posts views Thread by Chris | last post: by
2 posts views Thread by goscottie | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.