OnClientClick="javascript:enableValidators(....) error

M

Morris Neuman

Hi,

I have a web page which allows users logged in to be able to change their
password, their password question and answer and their email address. Though
this info is all on one page, I want the user to be able to change just the
password, or the question and answer, or the email - each component
individually.

I am using the ChangePassword control for the passwrod and custom controls
for the other changes. I have set-up individual RequiresFieldValidators and
set up 2 ValidationGroups (password, question, answer are in Group1, email is
in group2).

When attempting to change the password question and answer I get error:
"AnswerRequiredValidator" is undefined.
When attempting to change the email address I get error
"EmailRequiredValidator" is undefined.

These error occur on the statements -
OnClientClick="javascript:enableValidators(AnswerRequiredValidator,QuestionRequiredValidator,OldPasswordRequiredValidator);"
OnClientClick="javascript:enableValidators(EmailRequiredValidator);"

Can you check my code and see why I would be getting this error?

My code is as follows:

<%@ Page Language="C#" MasterPageFile="~/MasterPage1.master" Title="Change
Password Page" %>

<script runat="server">

protected void ChangePassword1_ChangedPassword(object sender, EventArgs e)
{


}

protected void ChangePasswordQuestion_OnClick(object sender, EventArgs
args)
{
try
{
MembershipUser u = Membership.GetUser(User.Identity.Name);
Boolean result =
u.ChangePasswordQuestionAndAnswer(PasswordTextbox.Text,
QuestionTextbox.Text,
AnswerTextbox.Text);

if (result)
Msg.Text = "Password Question and Answer changed.";
else
Msg.Text = "Password Question and Answer change failed.";
}
catch (Exception e)
{
Msg.Text = "Change failed. Please re-enter your values and try
again.";
}
}


MembershipUser u;
protected void Page_Load(object sender, EventArgs args)
{
u = Membership.GetUser(User.Identity.Name);

if (!IsPostBack)
{
EmailTextBox.Text = u.Email;
}
}

protected void UpdateEmailButton_OnClick(object sender, EventArgs args)
{
try
{
u.Email = EmailTextBox.Text;

Membership.UpdateUser(u);

Msg2.Text = "User e-mail updated.";
}
catch (System.Configuration.Provider.ProviderException e)
{
Msg2.Text = e.Message;
}
}

</script>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">
<span style="font-family: Verdana">
<br />
</span>
<table style="width: 582px">
<tr>
<td style="width: 457px; text-align: center; height: 47px;"
colspan="2">
<span style="font-size: large; font-family:
Verdana;">Account Information for </span>
<asp:LoginName ID="LoginName2" runat="server" Width="63px"
Font-Bold="False"
ForeColor="Navy" Font-Size="Large"
style="font-family: Verdana; font-size: large" />
</td>
</tr>
<tr>
<td style="width: 457px; text-align: center; height: 47px;"
colspan="2">
<span style="font-size: small; font-family: Verdana;
font-weight: bold;">Change your password</span><br />
<span style="font-family: Verdana">
<strong>
<asp:HyperLink ID="HyperLink1" runat="server"
Font-Names="Verdana" Font-Size="Smaller"
NavigateUrl="~/RecoverPassword.aspx"
Width="172px">Forgot your password?</asp:HyperLink>
</strong></span>
<br />
</td>
</tr>
<tr>
<td style="width: 457px; height: 150px;" colspan="2">
<asp:ChangePassword ID="ChangePassword1" runat="server"
ContinueDestinationPageUrl="~/Default.aspx" ChangePasswordTitleText=""
Font-Names="Verdana" Font-Size="10pt" Width="453px" Font-Bold="False"
OnChangedPassword="ChangePassword1_ChangedPassword"
CancelDestinationPageUrl="~/Default.aspx">
</asp:ChangePassword>
</td>
</tr>
<tr>
<td style="width: 457px; height: 28px; text-align: center"
colspan="2">
-------------------------------------------------------
</td>
</tr>
</table>

<table>
<tr>
<td style="height: 28px; text-align: center" colspan="2">
<span style="font-size: medium">
<br />
<b style="font-family: Verdana; font-size: small;
font-weight: bold">Change Password Question and Answer</b><br />
<asp:Label ID="Msg" ForeColor="maroon" runat="server"
style="font-size: small; font-family: Verdana;"
/></span>
</td>
</tr>

<tr>
<td style="width: 379px; height: 28px; text-align: right">
<span style="font-size: small; font-family:
Verdana;">Password:</span>
</td>
<td style="width: 400px; height: 28px; text-align: left">

<asp:TextBox ID="PasswordTextbox" runat="server"
TextMode="Password" />
<span style="font-family: Verdana">
<asp:RequiredFieldValidator
ID="OldPasswordRequiredValidator" runat="server"
ControlToValidate="PasswordTextbox"
ForeColor="red" Display="Static" ErrorMessage="*"
style="font-size: small" ValidationGroup="Group1"
/></span>
</td>
</tr>
<tr>
<td style="width: 379px; height: 28px; text-align: right">
<span style="font-family: Verdana; font-size: small;"> <span
style="font-weight: normal">New Password
Question:</span> </span>
</td>
<td style="width: 400px; height: 28px; text-align: left">
<span style="font-family: Verdana"></span>
<asp:TextBox ID="QuestionTextbox" MaxLength="256"
Columns="60" runat="server"
Width="350px" />

<asp:RequiredFieldValidator ID="QuestionRequiredValidator"
runat="server" ControlToValidate="QuestionTextbox"
ForeColor="red" Display="Static" ErrorMessage="*"
style="font-size: small" ValidationGroup="Group1" />
</td>
</tr>
<tr>
<td style="text-align: right; width: 379px;">
<span style="font-size: small; width: 239px; text-align:
right; font-family: Verdana;">
</span>
<span style="font-size: small; width: 239px; text-align:
right; font-family: Verdana;">
New Password Answer:</span></td>
<td style="font-size: small; width: 400px;">
<span style="font-family: Verdana">
<asp:TextBox ID="AnswerTextbox" MaxLength="128" Columns="60"
runat="server" Width="350px" />

<asp:RequiredFieldValidator ID="AnswerRequiredValidator"
runat="server" ControlToValidate="AnswerTextbox"
ForeColor="red" Display="Static" ErrorMessage="*"
style="font-size: small" ValidationGroup="Group1"
/></span>
</td>
</tr>
<tr>
<td style="height: 28px; text-align: center" colspan="2">
<strong>
<asp:Button ID="ChangePasswordQuestionButton" InputType =
"button"
Text="Change Password Question and Answer"
OnClientClick="javascript:enableValidators(AnswerRequiredValidator,QuestionRequiredValidator,OldPasswordRequiredValidator);"
OnClick="ChangePasswordQuestion_OnClick"
runat="server"
ValidationGroup="Group1" /> </strong>
</td>
</tr>

<tr>
<td style="height: 28px; text-align: center" colspan="2">
--------------------------------------------------------</td>
</tr>

</table>


<br />

<table>
<tr>
<td colspan="3" style="height: 27px; text-align: center">


<span style="font-family: Verdana; font-size: small; font-weight:
bold">Change
Email</span><br />


<asp:Label id="Msg2" ForeColor="Maroon" runat="server" Font-Names="Verdana"
Font-Size="Small" /></td>
</tr>
<tr>
<td style="font-family: Verdana; font-size: small; text-align: right;
width: 246px">E-mail Address:</td>
<td style="width: 317px"><asp:TextBox id="EmailTextBox" MaxLength="128"
Columns="30" runat="server" Width="310px" /></td>
<td><asp:RequiredFieldValidator id="EmailRequiredValidator"
runat="server"
ControlToValidate="EmailTextBox"
ForeColor="red"
Display="Static" ErrorMessage="*"
ValidationGroup="Group2" /></td>
</tr>
<tr>
<td style="width: 246px"></td>
<td style="width: 317px"><asp:Button id="UpdateEmailButton"
Text="Update E-mail"

OnClientClick="javascript:enableValidators(EmailRequiredValidator);"
OnClick="UpdateEmailButton_OnClick"
runat="server" /></td>
</tr>
</table>


</asp:Content>
 
A

Allen Chen [MSFT]

Hi Morris,

Where's the definition of the following JavaScript function?

OnClientClick="javascript:enableValidators(AnswerRequiredValidator,QuestionR
equiredValidator,OldPasswordRequiredValidator);"
OnClientClick="javascript:enableValidators(EmailRequiredValidator);"

By passing EmailRequiredValidator to the function it means you're passing
an object. If you want to pass a string as the parameter you can try
"EmailRequiredValidator". If you don't need these two functions please
delete them. Do you see the JavaScript error if you delete the above code?

BTW have you tested my code in your another thread Check for table? Can it
work?

http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?query=Che
ck+for+table+Morris+Neuman&dg=microsoft.public.dotnet.framework.aspnet.webco
ntrols&cat=en_US_d52a8b7e-8d01-4d6c-8b34-91f5e71bcffd&lang=en&cr=US&pt=&catl
ist=&dglist=&ptlist=&exp=&sloc=en-us


Regards,
Allen Chen
Microsoft Online Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Morris Neuman

Hi Allen

1) Not sure why I had the javascript statement as I did not have a
supporting function. I removed the statement and code works just fine.
Thanks.

2) Re the Check for table, I did try but forgot to post the result. I got
different errors and will post there today.

3) I tried sending you a direct email but the mail delivery was rejected.
Here is my issue:
My company SpeechSoft, Inc. is a certified Microsoft partner (Organization
ID 1633501) and as such has access to the MSDN Discussion Group forum.
We have 2 associate user ids – (e-mail address removed) and
(e-mail address removed).

When my colleague posts a question using her user id
([email protected]), she doesn’t get a response. However, when I posts a
question using my user id ([email protected]), I gets a response within
24 hours – thanks mostly to your responses.

We brought this issue up with the partner program support group and they
don’t see any difference in the 2 user ids and referred us to the MSDN
support group for further assistance. Since you have been very helpful in
addressing a lot of our questions, I thought I would bring this up to you to
see if my colleague’s user id ([email protected]) can be set-up to
receive the same response level as mine.

Thanks for any help and suggestions you can provide.
 
A

Allen Chen [MSFT]

Hi Morris,

Thanks for your update. We can continue our discussion in the Check for
table thread. Since this issue has been solved would you mind that I close
this case? For the issue that your colleague didn't get any response from
us in the Newsgroup you can read the following article first:

http://blogs.msdn.com/msdnts/pages/postingAlias.aspx

If you still have questions on it you can contact our engineer via the
following link:
https://support.microsoft.com/contactus/emailcontact.aspx?scid=sw;en;1296&sh
owpage=1&ws=msdn&sd=msdn&pa=msdnw

Our dedicated engineer will work with you on this issue.


Regards,
Allen Chen
Microsoft Online Support
 
M

Morris Neuman

Yes, please close this case.

Thanks for your reply to the support group. We will contact them to see if
we can resolve.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top