Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MaskedEditValidator not working in MultiView

Posted on 2007-11-21
7
Medium Priority
?
2,115 Views
Last Modified: 2012-05-05
Hello, everyone!

This seems like such a major bug, I am thinking I must be doing something wrong, but I can't figure out what.  I am trying to use some controls with MaskedEditExtenders and MaskedEditValidators inside a MultiView.   In this example the validator is in view A2.  I am OK going from A1 to  A2 and back to A1.  However, the second time I try to switch to A2 I get this error:

Microsoft JScript runtime error: Sys.ArgumentNullException: Value cannot be null.
Parameter name: element

If I remove the MaskedEditValidator I don't get this error.  I am using the latest version of the Ajax Controls Toolkit.  Any ideas?  



<%@ Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
        <ajaxToolkit:ToolkitScriptManager ID="ScriptManager1" runat="server" />
        <div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional" >
<ContentTemplate>
  <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"  >            
     <asp:View ID="A1" runat="server">
          This is view A1
           <div>
             <asp:TextBox ID="T2" runat="server"></asp:TextBox>
          </div>
             <asp:TextBox ID="D1012" runat="server"></asp:TextBox>  
          </div>
     </asp:View>
      <asp:View ID="A2" runat="server">
          This is view A2
          <div>
<ajaxToolkit:MaskedEditValidator ID="rfv" runat="server"
ControlExtender="maskPhone"
            ControlToValidate="TextBox1"
            ValidationExpression="^[2-9]\d{2}-\d{3}-\d{4}$"
            IsValidEmpty="true"
            InvalidValueMessage="Phone is invalid"
            Display="Dynamic"
            EmptyValueBlurredText="empty"
            InvalidValueBlurredMessage="invalid"></ajaxToolkit:MaskedEditValidator>
            <asp:TextBox ID="TextBox1" runat="server" Width="80" CssClass="TextAndNumberFonts"></asp:TextBox>
<ajaxToolkit:MaskedEditExtender ID="maskPhone" Runat="Server"
		 AutoComplete="False"
		 TargetControlID="TextBox1" 
		 Mask="999-999-9999" 
		 InputDirection="LeftToRight"
		 ClearMaskOnLostFocus="False" />
          </div>
          <div>
          <asp:TextBox ID="t1" runat="server"></asp:TextBox>
          </div>
   </asp:View>
 </asp:MultiView>
  <br/><br />
     <asp:Button ID="btnPrev2" Text="Previous"  runat="server" OnClick="btnPrev_Click" />
     <asp:Button ID="btnNext2" Text="Next" runat="server" OnClick="btnNext_Click"  />
 </ContentTemplate>
</asp:UpdatePanel>
        </div>
 
    </form>
</body>
</html>
 
 
And the codebehind:
 
Partial Class _Default
    Inherits System.Web.UI.Page
 
    Protected Sub btnPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If MultiView1.ActiveViewIndex = 0 Then
            MultiView1.ActiveViewIndex = MultiView1.Views.Count - 1
        Else
            MultiView1.ActiveViewIndex -= 1
        End If
    End Sub
 
    Protected Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs)
        If MultiView1.ActiveViewIndex = MultiView1.Views.Count - 1 Then
            MultiView1.ActiveViewIndex = 0
        Else
            MultiView1.ActiveViewIndex += 1
        End If
    End Sub
 
End Class

Open in new window

0
Comment
Question by:sophianewbie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 27

Expert Comment

by:Sammy Ageil
ID: 20450921
Sophia,
This error will only happen in debug mode
stop the debugger and test the script in a browser, you should not see this error
I just ran your code as it is and had no problem with it as long as I am not in debug mode

0
 

Author Comment

by:sophianewbie
ID: 20451552
Sammy,
I tried it in the browser, but unfortunately, while I don't get the error, the validation doesn't work either.  If you uncheck your Disable Script Debugging option in the browser you will see that the error occurs even when not in debug mode.  It's just ignored if that option if disabled.
0
 
LVL 27

Expert Comment

by:Sammy Ageil
ID: 20451786
I dont have disable script debugging disabled and the validation worked fine for me
which version of Ajax and asp.net are you using?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:sophianewbie
ID: 20451942
ASP.NET ver. 2.0.5.0727
ASP.NET Ajax ver. 1.0
AjaxControlsToolkit.dll from 9/20/2007
0
 
LVL 27

Expert Comment

by:Sammy Ageil
ID: 20452051
Ok that explains it then
I am running VS.Net 2008 and farmework 3.5. I know there are some differences between the 2 versions in Ajax

0
 

Author Comment

by:sophianewbie
ID: 20452124
Well, we are planning to upgrade to ASP.NET 3.5, but not today :)  So, in the meantime, I'm SOL?
0
 
LVL 27

Accepted Solution

by:
Sammy Ageil earned 2000 total points
ID: 20452149
I am sorry but it looks like you are SOL
I dont have VS 2005 to even try anything and I just did a fresh install of windows with only .Net 3.5
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question