Tags: ajax, aspnet, box, button, entry, maskededitextender, maskededitvalidator, net, page, redirect, text, validthe

MaskedEditExtender + MaskedEditValidator problem

On .Net » ASP.NET AJAX

11,782 words with 3 Comments; publish: Sun, 06 Jan 2008 06:32:00 GMT; (10093.75, « »)

Hi,

i have a text box, a MaskedEditExtender , a MaskedEditValidator and a button to redirect to another page if the text box entry is valid

The maskedEditExtender and validator is to validate the text box for a date format.

If i entered an invalid date format, the error message will display

but the problem is that if I hit the button, it will still redirect to another page even the text box is not valid.

For the regular asp.net validator like require field validator, if the textbox is empty and if i hit the button, it won't allow me to procee any further.

But how come if i use the maskedEditValidtor, i will behave differently ?

I have also tried to use the Page.IsValid property for the masketeditValidator.

But it will evaluate as true regarless the input format, is it a bug ?

thank you very much

All Comments

Leave a comment...

  • 3 Comments
    • Code please

      (please use the 'Source Code' button top-right of the rich editor)

      #1; Sun, 06 Jan 2008 06:33:00 GMT
    • Hi Thank you very much

      I have tried to use the source code button on the top but it won't return all the code that I have pasted......

      So, here is the code that i used.

      thank you very much

      <div>

      <ajaxToolkit:ToolkitScriptManagerrunat="server"ID="ScriptManager1"EnableScriptGlobalization="true"EnableScriptLocalization="true"/>

      <asp:TextBoxID="txtBox_Date"runat="server"ValidationGroup="MKE"></asp:TextBox>

      <ajaxToolkit:MaskedEditExtenderID="MaskedEditExtender5"runat="server"

      TargetControlID="txtBox_Date"

      Mask="99/99/9999"

      MessageValidatorTip="true"

      CultureName="en-US"

      OnFocusCssClass="MaskedEditFocus"

      OnInvalidCssClass="MaskedEditError"

      MaskType="Date"

      DisplayMoney="Left"

      AcceptNegative="Left"

      ErrorTooltipEnabled="True"/>

      <ajaxToolkit:MaskedEditValidatorID="MaskedEditValidator5"runat="server"

      ControlExtender="MaskedEditExtender5"

      ControlToValidate="txtBox_Date"

      EmptyValueMessage="Date is required"

      InvalidValueMessage="Date is invalid"

      Display="Dynamic"

      TooltipMessage="Input b date"

      EmptyValueBlurredText="*"

      InvalidValueBlurredMessage="*"

      ValidationGroup="MKE"/>

      <asp:ButtonID="readfasdfadsf"runat="server"OnClick="readfasdfadsf_Click1"/>

      </div>

      #2; Sun, 06 Jan 2008 06:34:00 GMT
    • Hi Nobody9999_9,

      I've checked your code. What i have done is removing your "ValidationGroup"property from TextBox and MaskedEditValidator. Now, it works fine.

      Here is the code.

      <%.net-ajax.todaysummary.com. Page Language="C#" AutoEventWireup="true" CodeFile="MarskEditTest.aspx.cs" Inherits="MaskedEditExtender_MarskEditTest" %>

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

      <html xmlns="http://www.w3.org/1999/xhtml">

      <head runat="server">

      <title>MarskEdit</title>

      </head>

      <body>

      <form id="form1" runat="server">

      <div>

      <%=DateTime.Now.ToString()%>

      <ajaxToolkit:ToolkitScriptManager runat="server" ID="ScriptManager1" EnableScriptGlobalization="true"

      EnableScriptLocalization="true" />

      <asp:TextBox ID="txtBox_Date" runat="server"></asp:TextBox>

      <ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender5" runat="server" TargetControlID="txtBox_Date"

      Mask="99/99/9999" MessageValidatorTip="true" CultureName="en-US" OnFocusCssClass="MaskedEditFocus"

      OnInvalidCssClass="MaskedEditError" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"

      ErrorTooltipEnabled="True"/>

      <ajaxToolkit:MaskedEditValidator ID="MaskedEditValidator5" runat="server" ControlExtender="MaskedEditExtender5"

      ControlToValidate="txtBox_Date" EmptyValueMessage="Date is required" InvalidValueMessage="Date is invalid"

      Display="Dynamic" TooltipMessage="Input b date" EmptyValueBlurredText="*" InvalidValueBlurredMessage="*"/>

      <asp:Button ID="btnClick" runat="server" Text="ClickHere" />

      </div>

      </form>

      </body>

      </html>

      Hope it helps. If I misunderstood you, please let me know.
      #3; Sun, 06 Jan 2008 06:35:00 GMT