PDA

View Full Version : [CLOSED] readonly property with input mask



metci
Jan 19, 2015, 9:31 AM
Hi,

I've the same problem with this post: http://forums.ext.net/showthread.php?27048-CLOSED-Masked-textfield-readonly-is-not-working

In this post you say that input mask can be disabled to make textfield readonly but at this time format of the value set to the textfield is lost. I wrote a small example to demonstrate this, when you run this example you'll see that the text field is readonly but the value appears as "11111111". When you comment out first line of the Page_load method, the value shows properly but the text field becomes editable.

Is there any solution for this problem?

Regards.




<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReadOnlyProblem.aspx.cs"
Inherits="ReadOnlyProblem" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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></title>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
InputMask10.Disable();
dtDateOfBirth.Text = "11.11.1111";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<div>
<ext:TextField ID="dtDateOfBirth" runat="server" FieldLabel="Date of Birth" ReadOnly="true">
<Plugins>
<ext:InputMask ID="InputMask10" runat="server" Mask="99.99.9999" ClearWhenInvalid="true"
Enabled="false" />
</Plugins>
</ext:TextField>
</div>
</form>
</body>
</html>

fabricio.murta
Jan 19, 2015, 4:01 PM
Hello,

Look what I've done:


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ReadOnlyProblem.aspx.cs"
Inherits="ExtNetPlayground.ReadOnlyProblem" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<!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></title>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
InputMask10.Disabled = true;
dtDateOfBirth.ReadOnly = true;
dtDateOfBirth.Text = "11.11.1111";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<div>
<ext:TextField ID="dtDateOfBirth" runat="server" FieldLabel="Date of Birth">
<Plugins>
<ext:InputMask ID="InputMask10" runat="server" Mask="99.99.9999" ClearWhenInvalid="true" />
</Plugins>
</ext:TextField>
</div>
</form>
</body>
</html>


Have I mentioned already that leaving the full test case helps a lot to find an answer for problems? :) Thank you!

Notice I removed any readonly or disabled from markup and moved them to the code behind. I think you can try them at will.

Notice also that

control.Disable();
is not the same as

control.Disabled = true;

(although they are almost the same)

Daniil
Jan 19, 2015, 4:09 PM
Hello everybody,

Just a small clarification on .Disabled and .Disable().

It is not recommended to use methods like .Disable() during an initial load request, because such methods are supposed/designed to be used during DirectEvents or DirectMethods.

As for .Disabled, you can use such properties during both - initial load requests and DirectEvents/DirectMethods.