By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,558 Members | 1,603 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,558 IT Pros & Developers. It's quick & easy.

Javascript in Customvalidator wont run on production web server

P: n/a
Hi there

I'm having a little bit of a problem with my customvalidator control.
The problem is the javascript runs fine on my local webserver IIS but
not when I post it to the web hosting server. As it is client side
scripting I'm suprised that this is the case as I'm using the same
browser IE6 and the same machine to access both. I've included the
code below.
Can anyone help . I've tried lowering all the security settings for
intranet and local intranet but to no avail!

Cheers
Ronan

<%@ Page Language="C#" Debug="true" Trace="true"
Src="..\CodeBehind\LogIn.cs" Inherits="EST.LogIn" %>
<script runat="server">

void Submit_Click(Object sender, EventArgs e)
{

GetLogIn();
}
void Send_Click(Object sender, EventArgs e)
{
SendEmail();

}

</script>
<html>
<head>
<link href="..\StyleSheets\BSF.css" type="text/css"
rel="stylesheet" />
<script language="javascript" id="clientEventHandlersJS">
function cvEmailPassword_Validate(source, arguments)
{
alert(source.id);

if (document.all("txtEmail").value != ""
&& document.all("txtPassword").value != "")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
function cvSendPassword_Validate(source, arguments)
{
alert(source.id);
if (document.all("txtSendEmail").value != ""
)
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
</script>
</head>
<body>
<form runat="server">
<table>
<tbody>
<tr>
<td>
Already registered? Log In here
</td>
</tr>
<tr>
<td>
<asp:Panel id="Panel1" runat="server"
width="450px" Height="95px" BorderStyle="Solid"
BackColor="LightSkyBlue">
<div align="left">
<asp:Table id="Table1" runat="server"
Height="74px">
<asp:TableRow>
<asp:TableCell Width= "70px">
<asp:Label runat="server"
id="lblEmail">Email</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
runat="server" Height="22px" ID="txtEmail"></asp:TextBox>
</asp:TableCell>
<asp:TableCell>

<asp:RegularExpressionValidator ID="valEmailAddress"
ControlToValidate="txtEmail" ValidationExpression=".*@.*\..*"
ErrorMessage="Email address is invalid." Display="None"
EnableClientScript="true" Runat="server" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server"
id="lblPassword">Password</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
TextMode="Password" runat="server" Height="22px"
ID="txtPassword"></asp:TextBox>
</asp:TableCell>

<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Button runat="server"
id = "btnLogIN" Text="LogIn" OnClick= "Submit_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</asp:Panel>
<asp:customvalidator id="cvEmailPassword"
runat="server" ErrorMessage="You need to enter an email address and
password." ClientValidationFunction="cvEmailPassword_Validate "
ControlToValidate="txtEmail"></asp:customvalidator>
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td>
Forgotton your password? Enter you email
address and click send.
</td>
</tr>
<tr>
<td>
<asp:Panel id="Panel2" runat="server"
width="450px" Height="95px" BorderStyle="Solid"
BackColor="LightSkyBlue">
<div align="left">
<asp:Table id="Table2" runat="server"
Height="74px">
<asp:TableRow>
<asp:TableCell Width= "70px">
<asp:Label runat="server"
id="lblSendEmail">Email</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
runat="server" Height="22px" ID="txtSendEmail"></asp:TextBox>
</asp:TableCell>

<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Button runat="server"
id = "btnSend" Text="Send" OnClick= "Send_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</asp:Panel>
<asp:customvalidator id="cvSendPassword"
runat="server" ErrorMessage="You need to enter a valid email address."
ClientValidationFunction="cvSendPassword_Validate"
ControlToValidate="txtSendEmail"
</asp:customvalidator>

</td>
</tr>
</tbody>
</table>
<br />
<asp:Label id="lblErrMessage" runat="server"></asp:Label>
<!-- Insert content here -->
</form>
</body>
</html>
Nov 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Have you verified that the validation folder is on the webserver as well.
Validation works by examining and using the files in this specific folder.
The path to this folder is found in the machine config file. Without the
folder, the run-time fails silently and validation doesn't work.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Ronan Dodworth" <rd*******@hotmail.com> wrote in message
news:1f**************************@posting.google.c om...
Hi there

I'm having a little bit of a problem with my customvalidator control.
The problem is the javascript runs fine on my local webserver IIS but
not when I post it to the web hosting server. As it is client side
scripting I'm suprised that this is the case as I'm using the same
browser IE6 and the same machine to access both. I've included the
code below.
Can anyone help . I've tried lowering all the security settings for
intranet and local intranet but to no avail!

Cheers
Ronan

<%@ Page Language="C#" Debug="true" Trace="true"
Src="..\CodeBehind\LogIn.cs" Inherits="EST.LogIn" %>
<script runat="server">

void Submit_Click(Object sender, EventArgs e)
{

GetLogIn();
}
void Send_Click(Object sender, EventArgs e)
{
SendEmail();

}

</script>
<html>
<head>
<link href="..\StyleSheets\BSF.css" type="text/css"
rel="stylesheet" />
<script language="javascript" id="clientEventHandlersJS">
function cvEmailPassword_Validate(source, arguments)
{
alert(source.id);

if (document.all("txtEmail").value != ""
&& document.all("txtPassword").value != "")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
function cvSendPassword_Validate(source, arguments)
{
alert(source.id);
if (document.all("txtSendEmail").value != ""
)
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
</script>
</head>
<body>
<form runat="server">
<table>
<tbody>
<tr>
<td>
Already registered? Log In here
</td>
</tr>
<tr>
<td>
<asp:Panel id="Panel1" runat="server"
width="450px" Height="95px" BorderStyle="Solid"
BackColor="LightSkyBlue">
<div align="left">
<asp:Table id="Table1" runat="server"
Height="74px">
<asp:TableRow>
<asp:TableCell Width= "70px">
<asp:Label runat="server"
id="lblEmail">Email</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
runat="server" Height="22px" ID="txtEmail"></asp:TextBox>
</asp:TableCell>
<asp:TableCell>

<asp:RegularExpressionValidator ID="valEmailAddress"
ControlToValidate="txtEmail" ValidationExpression=".*@.*\..*"
ErrorMessage="Email address is invalid." Display="None"
EnableClientScript="true" Runat="server" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server"
id="lblPassword">Password</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
TextMode="Password" runat="server" Height="22px"
ID="txtPassword"></asp:TextBox>
</asp:TableCell>

<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Button runat="server"
id = "btnLogIN" Text="LogIn" OnClick= "Submit_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</asp:Panel>
<asp:customvalidator id="cvEmailPassword"
runat="server" ErrorMessage="You need to enter an email address and
password." ClientValidationFunction="cvEmailPassword_Validate "
ControlToValidate="txtEmail"></asp:customvalidator>
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td>
Forgotton your password? Enter you email
address and click send.
</td>
</tr>
<tr>
<td>
<asp:Panel id="Panel2" runat="server"
width="450px" Height="95px" BorderStyle="Solid"
BackColor="LightSkyBlue">
<div align="left">
<asp:Table id="Table2" runat="server"
Height="74px">
<asp:TableRow>
<asp:TableCell Width= "70px">
<asp:Label runat="server"
id="lblSendEmail">Email</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
runat="server" Height="22px" ID="txtSendEmail"></asp:TextBox>
</asp:TableCell>

<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Button runat="server"
id = "btnSend" Text="Send" OnClick= "Send_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</asp:Panel>
<asp:customvalidator id="cvSendPassword"
runat="server" ErrorMessage="You need to enter a valid email address."
ClientValidationFunction="cvSendPassword_Validate"
ControlToValidate="txtSendEmail"
</asp:customvalidator>

</td>
</tr>
</tbody>
</table>
<br />
<asp:Label id="lblErrMessage" runat="server"></asp:Label>
<!-- Insert content here -->
</form>
</body>
</html>

Nov 18 '05 #2

P: n/a
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message news:<uz**************@TK2MSFTNGP10.phx.gbl>...
Have you verified that the validation folder is on the webserver as well.
Validation works by examining and using the files in this specific folder.
The path to this folder is found in the machine config file. Without the
folder, the run-time fails silently and validation doesn't work.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Ronan Dodworth" <rd*******@hotmail.com> wrote in message
news:1f**************************@posting.google.c om...
Hi there

I'm having a little bit of a problem with my customvalidator control.
The problem is the javascript runs fine on my local webserver IIS but
not when I post it to the web hosting server. As it is client side
scripting I'm suprised that this is the case as I'm using the same
browser IE6 and the same machine to access both. I've included the
code below.
Can anyone help . I've tried lowering all the security settings for
intranet and local intranet but to no avail!

Cheers
Ronan

<%@ Page Language="C#" Debug="true" Trace="true"
Src="..\CodeBehind\LogIn.cs" Inherits="EST.LogIn" %>
<script runat="server">

void Submit_Click(Object sender, EventArgs e)
{

GetLogIn();
}
void Send_Click(Object sender, EventArgs e)
{
SendEmail();

}

</script>
<html>
<head>
<link href="..\StyleSheets\BSF.css" type="text/css"
rel="stylesheet" />
<script language="javascript" id="clientEventHandlersJS">
function cvEmailPassword_Validate(source, arguments)
{
alert(source.id);

if (document.all("txtEmail").value != ""
&& document.all("txtPassword").value != "")
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
function cvSendPassword_Validate(source, arguments)
{
alert(source.id);
if (document.all("txtSendEmail").value != ""
)
{
arguments.IsValid = true;
}
else
{
arguments.IsValid = false;
}
}
</script>
</head>
<body>
<form runat="server">
<table>
<tbody>
<tr>
<td>
Already registered? Log In here
</td>
</tr>
<tr>
<td>
<asp:Panel id="Panel1" runat="server"
width="450px" Height="95px" BorderStyle="Solid"
BackColor="LightSkyBlue">
<div align="left">
<asp:Table id="Table1" runat="server"
Height="74px">
<asp:TableRow>
<asp:TableCell Width= "70px">
<asp:Label runat="server"
id="lblEmail">Email</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
runat="server" Height="22px" ID="txtEmail"></asp:TextBox>
</asp:TableCell>
<asp:TableCell>

<asp:RegularExpressionValidator ID="valEmailAddress"
ControlToValidate="txtEmail" ValidationExpression=".*@.*\..*"
ErrorMessage="Email address is invalid." Display="None"
EnableClientScript="true" Runat="server" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Label runat="server"
id="lblPassword">Password</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
TextMode="Password" runat="server" Height="22px"
ID="txtPassword"></asp:TextBox>
</asp:TableCell>

<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Button runat="server"
id = "btnLogIN" Text="LogIn" OnClick= "Submit_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</asp:Panel>
<asp:customvalidator id="cvEmailPassword"
runat="server" ErrorMessage="You need to enter an email address and
password." ClientValidationFunction="cvEmailPassword_Validate "
ControlToValidate="txtEmail"></asp:customvalidator>
</td>
</tr>
<tr>
<td>
<br />
</td>
</tr>
<tr>
<td>
Forgotton your password? Enter you email
address and click send.
</td>
</tr>
<tr>
<td>
<asp:Panel id="Panel2" runat="server"
width="450px" Height="95px" BorderStyle="Solid"
BackColor="LightSkyBlue">
<div align="left">
<asp:Table id="Table2" runat="server"
Height="74px">
<asp:TableRow>
<asp:TableCell Width= "70px">
<asp:Label runat="server"
id="lblSendEmail">Email</asp:Label>
</asp:TableCell>
<asp:TableCell>
<asp:TextBox
runat="server" Height="22px" ID="txtSendEmail"></asp:TextBox>
</asp:TableCell>

<asp:TableCell></asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell>
<asp:Button runat="server"
id = "btnSend" Text="Send" OnClick= "Send_Click" />
</asp:TableCell>
</asp:TableRow>
</asp:Table>
</div>
</asp:Panel>
<asp:customvalidator id="cvSendPassword"
runat="server" ErrorMessage="You need to enter a valid email address."
ClientValidationFunction="cvSendPassword_Validate"
ControlToValidate="txtSendEmail"
</asp:customvalidator>

</td>
</tr>
</tbody>
</table>
<br />
<asp:Label id="lblErrMessage" runat="server"></asp:Label>
<!-- Insert content here -->
</form>
</body>
</html>

Alvin
Many thanks for that.
But just to be sure (I'm new to validation controls and .NET in
general )
is this the path you are talking about? . I got this from viewing the
rendered html on my local IIS
'/aspnet_client/system_web/1_1_4322/WebUIValidation.js'
Also is this the Machine config file setting you are talking about?

<webControls clientScriptsLocation="/aspnet_client/{0}/{1}/"/>

Regards

Ronan
Nov 18 '05 #3

P: n/a
right, there needs to be a folder at the end of this path on the server for
validation to work correctly

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Ronan Dodworth" <rd*******@hotmail.com> wrote in message
news:1f*************************@posting.google.co m...
"Alvin Bruney [MVP]" <vapor at steaming post office> wrote in message
news:<uz**************@TK2MSFTNGP10.phx.gbl>...
Have you verified that the validation folder is on the webserver as well.
Validation works by examining and using the files in this specific
folder.
The path to this folder is found in the machine config file. Without the
folder, the run-time fails silently and validation doesn't work.

--
Regards,
Alvin Bruney
[ASP.NET MVP http://mvp.support.microsoft.com/default.aspx]
Got tidbits? Get it here... http://tinyurl.com/27cok
"Ronan Dodworth" <rd*******@hotmail.com> wrote in message
news:1f**************************@posting.google.c om...
> Hi there
>
> I'm having a little bit of a problem with my customvalidator control.
> The problem is the javascript runs fine on my local webserver IIS but
> not when I post it to the web hosting server. As it is client side
> scripting I'm suprised that this is the case as I'm using the same
> browser IE6 and the same machine to access both. I've included the
> code below.
> Can anyone help . I've tried lowering all the security settings for
> intranet and local intranet but to no avail!
>
> Cheers
>
>
> Ronan
>
>
>
> <%@ Page Language="C#" Debug="true" Trace="true"
> Src="..\CodeBehind\LogIn.cs" Inherits="EST.LogIn" %>
> <script runat="server">
>
> void Submit_Click(Object sender, EventArgs e)
> {
>
> GetLogIn();
> }
> void Send_Click(Object sender, EventArgs e)
> {
> SendEmail();
>
> }
>
> </script>
> <html>
> <head>
> <link href="..\StyleSheets\BSF.css" type="text/css"
> rel="stylesheet" />
> <script language="javascript" id="clientEventHandlersJS">
>
>
> function cvEmailPassword_Validate(source, arguments)
> {
> alert(source.id);
>
> if (document.all("txtEmail").value != ""
> && document.all("txtPassword").value != "")
> {
> arguments.IsValid = true;
> }
> else
> {
> arguments.IsValid = false;
> }
> }
> function cvSendPassword_Validate(source, arguments)
> {
> alert(source.id);
> if (document.all("txtSendEmail").value != ""
> )
> {
> arguments.IsValid = true;
> }
> else
> {
> arguments.IsValid = false;
> }
> }
> </script>
> </head>
> <body>
> <form runat="server">
> <table>
> <tbody>
> <tr>
> <td>
> Already registered? Log In here
> </td>
> </tr>
> <tr>
> <td>
> <asp:Panel id="Panel1" runat="server"
> width="450px" Height="95px" BorderStyle="Solid"
> BackColor="LightSkyBlue">
> <div align="left">
> <asp:Table id="Table1" runat="server"
> Height="74px">
> <asp:TableRow>
> <asp:TableCell Width= "70px">
> <asp:Label runat="server"
> id="lblEmail">Email</asp:Label>
> </asp:TableCell>
> <asp:TableCell>
> <asp:TextBox
> runat="server" Height="22px" ID="txtEmail"></asp:TextBox>
> </asp:TableCell>
> <asp:TableCell>
>
> <asp:RegularExpressionValidator ID="valEmailAddress"
> ControlToValidate="txtEmail" ValidationExpression=".*@.*\..*"
> ErrorMessage="Email address is invalid." Display="None"
> EnableClientScript="true" Runat="server" />
> </asp:TableCell>
> </asp:TableRow>
> <asp:TableRow>
> <asp:TableCell>
> <asp:Label runat="server"
> id="lblPassword">Password</asp:Label>
> </asp:TableCell>
> <asp:TableCell>
> <asp:TextBox
> TextMode="Password" runat="server" Height="22px"
> ID="txtPassword"></asp:TextBox>
> </asp:TableCell>
>
> <asp:TableCell></asp:TableCell>
> </asp:TableRow>
> <asp:TableRow>
> <asp:TableCell>
> <asp:Button runat="server"
> id = "btnLogIN" Text="LogIn" OnClick= "Submit_Click" />
> </asp:TableCell>
> </asp:TableRow>
> </asp:Table>
> </div>
> </asp:Panel>
> <asp:customvalidator id="cvEmailPassword"
> runat="server" ErrorMessage="You need to enter an email address and
> password." ClientValidationFunction="cvEmailPassword_Validate "
> ControlToValidate="txtEmail"></asp:customvalidator>
> </td>
> </tr>
> <tr>
> <td>
> <br />
> </td>
> </tr>
> <tr>
> <td>
> Forgotton your password? Enter you email
> address and click send.
> </td>
> </tr>
> <tr>
> <td>
> <asp:Panel id="Panel2" runat="server"
> width="450px" Height="95px" BorderStyle="Solid"
> BackColor="LightSkyBlue">
> <div align="left">
> <asp:Table id="Table2" runat="server"
> Height="74px">
> <asp:TableRow>
> <asp:TableCell Width= "70px">
> <asp:Label runat="server"
> id="lblSendEmail">Email</asp:Label>
> </asp:TableCell>
> <asp:TableCell>
> <asp:TextBox
> runat="server" Height="22px" ID="txtSendEmail"></asp:TextBox>
> </asp:TableCell>
>
> <asp:TableCell></asp:TableCell>
> </asp:TableRow>
> <asp:TableRow>
> <asp:TableCell>
> <asp:Button runat="server"
> id = "btnSend" Text="Send" OnClick= "Send_Click" />
> </asp:TableCell>
> </asp:TableRow>
> </asp:Table>
> </div>
> </asp:Panel>
> <asp:customvalidator id="cvSendPassword"
> runat="server" ErrorMessage="You need to enter a valid email address."
> ClientValidationFunction="cvSendPassword_Validate"
> ControlToValidate="txtSendEmail"
>></asp:customvalidator>
> </td>
> </tr>
> </tbody>
> </table>
> <br />
> <asp:Label id="lblErrMessage" runat="server"></asp:Label>
> <!-- Insert content here -->
> </form>
> </body>
> </html>

Alvin
Many thanks for that.
But just to be sure (I'm new to validation controls and .NET in
general )
is this the path you are talking about? . I got this from viewing the
rendered html on my local IIS
'/aspnet_client/system_web/1_1_4322/WebUIValidation.js'
Also is this the Machine config file setting you are talking about?

<webControls clientScriptsLocation="/aspnet_client/{0}/{1}/"/>

Regards

Ronan

Nov 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.