Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Client Validation Javascript not rendering

Reply
Thread Tools

Client Validation Javascript not rendering

 
 
=?Utf-8?B?Rm91cmdl?=
Guest
Posts: n/a
 
      01-25-2005
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:
 
Reply With Quote
 
 
 
 
Peter Blum
Guest
Posts: n/a
 
      01-25-2005
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: http://www.velocityreviews.com/forums/(E-Mail Removed)
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

"Fourge" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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:



 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      01-26-2005
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.)

 
Reply With Quote
 
vitorrubio vitorrubio is offline
Junior Member
Join Date: Jul 2010
Posts: 1
 
      07-21-2010
I had the same problem, and I trying to access a simple page with only one TextBox, one RequiredFieldValidator and one button.

I'm using .Net framework 1.1 and visual studio 2003

I have three servers: one with windows XP sp2 (development) and other two with Windows 2003 server and IIS 6.
The client - code rendered by the Win xp machine works, and the client validation works fine, but the code rendered by the win 2003 machine doesn't work.
Below the codes:


working code ...

HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  ...

  <body MS_POSITIONING="GridLayout">
	
    <form method="post" action="teste.aspx" onsubmit="javascript:return WebForm_OnSubmit();" id="Form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKMTcyMzUyODc3OWRkgRhvsR5UK3vvocXrO1qomevAnDqvQLEIr9xosJzc144=" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['Form1'];
if (!theForm) {
    theForm = document.Form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<s c r i p t s r c="/VendasPortal/WebResource.axd?d=Y9yRm5JYEUG0635f1BSfHg2&amp;t=634109895716662567" type="text/javascript"></script>

[B]<script src="/VendasPortal/WebResource.axd?d=DmxOgWmpaO0fHDXSwAhjW05EVUsM6EimrZSGOo1mVPk1&amp;t=634109895716662567" type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function WebForm_OnSubmit() {
if (typeof(ValidatorOnSubmit) == "function" && ValidatorOnSubmit() == false) return false;
return true;
}
//]]>
</script>[/B]

<div class="aspNetHidden">

	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAwLCiPquAgLs0bLrBgKM54rGBhzafW1C+OfPIJPDNNAdnRbXCW+QuT0S6TfTUi17hdWP" />
</div><input name="TextBox1" type="text" id="TextBox1" style="Z-INDEX: 101; POSITION: absolute; TOP: 56px; LEFT: 264px" /><input type="submit" name="Button1" value="Button" onclick="[B]javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions(&quot;Button1&quot;, &quot;&quot;, true, &quot;&quot;, &quot;&quot;, false, false))[/B]" id="Button1" style="Z-INDEX: 102; POSITION: absolute; TOP: 112px; LEFT: 264px" /><span id="RequiredFieldValidator1" style="Z-INDEX:103;POSITION:absolute;TOP:56px;LEFT:440px;visibility:hidden;">RequiredFieldValidator</span><div id="ValidationSummary1" style="Z-INDEX:104;POSITION:absolute;TOP:104px;LEFT:384px;display:none;">

</div>

     
<script type="text/javascript">
//<![CDATA[
var Page_ValidationSummaries =  new Array(document.getElementById("ValidationSummary1"));
var Page_Validators =  new Array(document.getElementById("RequiredFieldValidator1"));
//]]>

</script>

[B]<script type="text/javascript">
//<![CDATA[
var RequiredFieldValidator1 = document.all ? document.all["RequiredFieldValidator1"] : document.getElementById("RequiredFieldValidator1");
RequiredFieldValidator1.controltovalidate = "TextBox1";
RequiredFieldValidator1.errormessage = "RequiredFieldValidator";
RequiredFieldValidator1.evaluationfunction = "RequiredFieldValidatorEvaluateIsValid";
RequiredFieldValidator1.initialvalue = "";
var ValidationSummary1 = document.all ? document.all["ValidationSummary1"] : document.getElementById("ValidationSummary1");
ValidationSummary1.showmessagebox = "True";
//]]>
</script>[/B]


<script type="text/javascript">
//<![CDATA[

var Page_ValidationActive = false;
if (typeof(ValidatorOnLoad) == "function") {
    ValidatorOnLoad();
}

function ValidatorOnSubmit() {
    if (Page_ValidationActive) {
        return ValidatorCommonOnSubmit();
    }
    else {
        return true;
    }
}
        //]]>
</script>
</form>
	
  </body>
</HTML>
the non-working code:
HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
 ...

  <body MS_POSITIONING="GridLayout">
	
    <form name="Form1" method="post" action="teste.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDwyNTc1Nzk2ODE7Oz5ZXN65Bn54k9P6APUWZPmu+eMTUw==" />
<input name="TextBox1" type="text" id="TextBox1" style="Z-INDEX: 101; POSITION: absolute; TOP: 56px; LEFT: 264px" /><input type="submit" name="Button1" value="Button" onclick="if (typeof(Page_ClientValidate) == 'function') Page_ClientValidate(); " language="javascript" id="Button1" style="Z-INDEX: 102; POSITION: absolute; TOP: 112px; LEFT: 264px" />&nbsp;

     </form>
	
  </body>
</HTML>
What can i do?
What i did wrong?

Sorry about my english.
 

Last edited by vitorrubio; 07-21-2010 at 07:27 PM..
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
ASP.NET Client Validation Javascript Partially Rendering Bill ASP .Net 1 07-15-2011 09:14 AM
Validation Summary not showing for client side validation cwhankey@gmail.com ASP .Net 1 12-12-2008 02:32 AM
IE6 SP1 rendering vs IE6 SP2 rendering Peter Mount HTML 4 01-31-2006 08:01 AM
Page is not submitted using Client side validation of.NET validation Sudip ASP .Net Web Controls 0 07-01-2005 05:49 AM
validation summary doesnt display when there's client-side validation Libs ASP .Net 0 06-25-2003 03:05 PM



Advertisments