[FIXED] [V0.8.0] Can't get/set value for TextField Readonly

  1. #1

    [FIXED] [V0.8.0] Can't get/set value for TextField Readonly



    Dear team,

    I found a strange behavior in code AjaxEvent for ext:textfield control.

    Refer to below code, "TextField" should be a readonly control, but the value can be change in ajaxevent when click "Button2". When click "Button1", the value of "TextField" will be copy to a normal control "Result", so to verify the control value.

    In below code, the set/get function is ok, when I click the button 1 and 2, the value can be update.

    But if I change the readonly property in aspx like below:
            <ext:TextField ID="TextField" runat="server" Text="test" ReadOnly="true" >
    or in Page_Load event:
            protected void Page_Load(object sender, EventArgs e)
            {
                TextField.ReadOnly = true;
            }
    the function is not ok, the text property of "TextField" is alwasy "test"(the init value).


    test.aspx:

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Web.test" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" 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>
    </head>
    <body>
        <ext:ScriptManager ID="ScriptManager1" runat="server">
        </ext:ScriptManager>
        
        <form id="form1" runat="server">
        
            <br />TextField: 
            <ext:TextField ID="TextField" runat="server" Text="test" ReadOnly="false" >
            </ext:TextField> 
            <ext:Button ID="Button1" runat="server" Text="testTextField">
                <AjaxEvents >
                    <Click OnEvent="testTextField"></Click>
                </AjaxEvents>
            </ext:Button>
            <ext:Button ID="Button2" runat="server" Text="setvalue">
                <AjaxEvents >
                    <Click OnEvent="setTextField"></Click>
                </AjaxEvents>
            </ext:Button>        
            
            <br />Result
            <ext:TextField ID="Result" runat="server">
            </ext:TextField> 
            <br />
        
        
    
        </form>
    </body>
    </html>
    test.aspx.cs
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Coolite.Ext;
    using Coolite.Ext.Web;
    namespace Web
    {
        public partial class test : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                //TextField.ReadOnly = true;
            }
    
    
            protected void testTextField(object sender, AjaxEventArgs e)
            {
                Result.Text = TextField.Text;
            }
    
    
            protected void setTextField(object sender, AjaxEventArgs e)
            {
                TextField.ReadOnly = true;
                TextField.Text = System.DateTime.Now.ToString() ;
            }
        }
    }
    I also test other ext control, same problem in textarea control, but no problem in ext:DateField and ext:Checkbox control when readonly set to true.
    Just for your reference, pls help find the rootcause, thanks.
  2. #2

    RE: [FIXED] [V0.8.0] Can't get/set value for TextField Readonly

    Hi,

    Try to set ViewStateMode="Include" for AjaxEvent.

    <ext:Button ID="Button2" runat="server" Text="setvalue">
    *** <AjaxEvents >
    ******* <Click ViewStateMode="Include" OnEvent="setTextField"></Click>
    *** </AjaxEvents>
    </ext:Button>

    Plus in 0.7 version the TextField and TextArea excluding from submit if they are ReadOnly (it can be a problem if you change it programatically on client side). In 0.8.0 it is changed (readonly text field submit your value)
  3. #3

    RE: [FIXED] [V0.8.0] Can't get/set value for TextField Readonly

    It works, thanks Vladimir, so kind of you.
    Pls mark this thread as resolved.

Similar Threads

  1. TextField ReadOnly
    By Penunuri in forum 1.x Help
    Replies: 3
    Last Post: Jul 20, 2009, 8:16 PM
  2. Replies: 2
    Last Post: Jun 17, 2009, 12:48 PM
  3. [CLOSED] Textfield Readonly Property
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Mar 24, 2009, 11:52 AM
  4. Replies: 2
    Last Post: Dec 24, 2008, 6:17 AM
  5. Replies: 1
    Last Post: Nov 21, 2008, 7:10 AM

Posting Permissions