ASP.NET - MaskedEditExtender + Time + Autocomplete

Asked By muthamilselvi manoharan on 01-Oct-08 02:33 AM

When I use a MaskedEditExtender for time entry with autocomplete on, the control

always completes with the current time exmpl: entered 12:__ --> current time on server is 12:14

it completes to 12:14 but I want it to complete to 12:00, what can I do?

Any suggestions?

Reply - Binny ch replied to muthamilselvi manoharan on 01-Oct-08 02:40 AM

use the property Autocompletevalue 

examle:

AcceptAMPM="True"
AutoCompleteValue="00:00"

Not working - muthamilselvi manoharan replied to Binny ch on 01-Oct-08 02:48 AM

Not working..

it shown like this

re - Web Star replied to muthamilselvi manoharan on 01-Oct-08 02:53 AM

For MaskType Time:
------------------------------
press the “:” key: move to next element date and filled with zeros (if has value in current element) 

For MaskType DateTime:
------------------------------------
Press the “:” key:  if cursor at before “time group”, move to first element of Time. If cursor inside of time group, move to next element time and filled with zeros (if has value in current element)

solution - Perry replied to muthamilselvi manoharan on 01-Oct-08 02:57 AM
Hi,

You can to use the property Autocompletevalue (autocompletevalue overwrite current time)

<ajaxToolkit:MaskedEditExtender ID="MaskedEditExtender3" runat="server" TargetControlID="TextBox3"
Mask="99:99"
MessageValidatorTip="true"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Time"
AcceptAMPM="True"
AutoCompleteValue="00:00"

CultureName="en-US" />

Btw, the route AutocompleteTime have a small bug. You can fix it by refering http://www.codeplex.com/AjaxControlToolkit/SourceControl/DownloadSourceCode.aspx?changeSetId=19659

Megha
reply - alice johnson replied to muthamilselvi manoharan on 01-Oct-08 02:58 AM
AutoFormatTime : function()

    {

              
        if (this._AutoCompleteValue != "" )

        {

            Mcur = this._AutoCompleteValue.substring(3,2); <---

            // replace to  this._AutoCompleteValue.substring(3,5)

        }

              
      if (this._maskvalid == "99" + this.get_CultureTimePlaceholder()…

        {

            if (this._AutoCompleteValue != "" )

            {

                Scur = this._AutoCompleteValue.substring(5); <-----

              // replace to  this._AutoCompleteValue.substring(6);

            }

 

Go through this link:

its similar to urs:

http://forums.asp.net/t/1084117.aspx

Bug fix - Perry replied to muthamilselvi manoharan on 01-Oct-08 02:59 AM
It seems the bug is because the substring function is wrote wrong at piece code  (The behavior of substring function is different  in JS to C#  ) . Partial code looks like below:

, AutoFormatTime : function()
    {
               …
        if (this._AutoCompleteValue != "" )
        {
            Mcur = this._AutoCompleteValue.substring(3,2); <---
            // replace to  this._AutoCompleteValue.substring(3,5)
        }
               …
      if (this._maskvalid == "99" + this.get_CultureTimePlaceholder()…
        {
            if (this._AutoCompleteValue != "" )
            {
                Scur = this._AutoCompleteValue.substring(5); <-----
              // replace to  this._AutoCompleteValue.substring(6);
            }

Megha
re - Web Star replied to muthamilselvi manoharan on 01-Oct-08 03:04 AM
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
       txtLogTime.Text = String.Format("{0:t}", DateTime.Now);    // it will set the TextBox's text as 11:20 AM
      
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server" />
    <asp:TextBox ID="txtLogTime" runat="server"></asp:TextBox>
    <ajaxToolkit:MaskedEditExtender ID="meeLogTime" runat="server" Mask="99:99" MaskType="Time"
        TargetControlID="txtLogTime" AutoComplete="true" AcceptAMPM="true">
    </ajaxToolkit:MaskedEditExtender>
    </form>
</body>
</html>
solution for your problem - C_A P replied to muthamilselvi manoharan on 01-Oct-08 04:32 AM
<script runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
       txtLogTime.Text = String.Format("{0:t}", DateTime.Now);    // it will set the TextBox's text as 11:20 AM
      
    }
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:ScriptManager ID="ScriptManager" runat="server" />
    <asp:TextBox ID="txtLogTime" runat="server"></asp:TextBox>
    <ajaxToolkit:MaskedEditExtender ID="meeLogTime" runat="server" Mask="99:99" MaskType="Time"
        TargetControlID="txtLogTime" AutoComplete="true" AcceptAMPM="true">
    </ajaxToolkit:MaskedEditExtender>
    </form>
</body>
</html>
try this one - C_A P replied to muthamilselvi manoharan on 01-Oct-08 04:32 AM
It seems the bug is because the substring function is wrote wrong at piece code  (The behavior of substring function is different  in JS to C#  ) . Partial code looks like below:

, AutoFormatTime : function()
    {
               …
        if (this._AutoCompleteValue != "" )
        {
            Mcur = this._AutoCompleteValue.substring(3,2); <---
            // replace to  this._AutoCompleteValue.substring(3,5)
        }
               …
      if (this._maskvalid == "99" + this.get_CultureTimePlaceholder()…
        {
            if (this._AutoCompleteValue != "" )
            {
                Scur = this._AutoCompleteValue.substring(5); <-----
              // replace to  this._AutoCompleteValue.substring(6);
            }