Javascript in Customvalidator wont run on production web server

R

Ronan Dodworth

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>
 
A

Alvin Bruney [MVP]

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.
 
R

Ronan Dodworth

Alvin Bruney said:
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 said:
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"
</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
 
A

Alvin Bruney [MVP]

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 said:
Alvin Bruney said:
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 said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top