About TextField Attribute Question

  1. #1

    About TextField Attribute Question

    if textfield use Attribute IsReadOnly or Enable="fasle" then i can't read text by AjaxMethod
    but some Field must be IsReadOnly.
  2. #2

    RE: About TextField Attribute Question

    Hi andyfoxcs !

    I have that problem too.

    What I've done so far is to add attributes to the texfield, so that way the control can be "readonly" without lose the value in an AjaxEvent.

    Here's what i've done:

    
    
    
    protected void Page_Load(object sender, EventArgs e)
    
    
    {
        if (!Page.IsPostBack)
        {
            // Read only attributes
            CoolTxtFld1.Attributes.Add("onkeypress", "return false;");
            CoolTxtFld1.Attributes.Add("onkeydown", "return false;");
        }
    }

    Hope this helps.
    Alfonso Penunuri.
  3. #3

    RE: About TextField Attribute Question



    BUMP

    I'm converting my postback pages to all ajax events and I just spent 3 hours trying to figure this out. :)


    Is this a bug?

  4. #4

    RE: About TextField Attribute Question

    Can you post a complete (but simplified) .aspx code sample demonstating the problem?

    I tried the following with the latest code-base (v0.8.0) and it appears to work as expected.

    Example

    <%@ Page Language="C#" %>
    
    <%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>
    
    <script runat="server">
    *** protected void Button1_Click(object sender, AjaxEventArgs e)
    *** {
    ******* this.Label1.Html = this.TextField1.Text;
    *** }
    </script>
    
    <!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 id="Head1" runat="server">
    *** <title>HtmlEditor</title>
    </head>
    <body>
    *** <ext:ScriptManager ID="ScriptManager1" runat="server" />
    *** 
    *** <form runat="server">
    *** 
    ******* <ext:TextField ID="TextField1" runat="server" ReadOnly="true" />
    
    ******* <ext:Button runat="server" Text="Save">
    *********** <AjaxEvents>
    *************** <Click OnEvent="Button1_Click" />
    *********** </AjaxEvents>
    ******* </ext:Button>
    ******* 
    ******* <ext:Label ID="Label1" runat="server" />
    
    *** </form>
    </body>
    </html>
    Hope this helps.

    Geoffrey McGill
    Founder
  5. #5

    RE: About TextField Attribute Question



    *Geoffrey,

    I modified your example to add the additional step*where the value is dropped/lost.

    If this is fixed in v0.8.0 can you*think of*a work around till then?

    What's the ETA on v0.8.0 :)

    <%@ Page Language="C#" %></p>
    
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %></p>
    
    
    <script runat="server">
    *** protected void Button1_Click(object sender, AjaxEventArgs e)
    *** {
    ******* this.TextField2.Text = this.TextField1.Text;</p>
    
    
    ******* if (!String.IsNullOrEmpty(this.TextField2.Text))
    ******* {
    *********** this.Label1.Html = this.TextField2.Text;
    ******* }
    *** }
    *** protected void Button2_Click(object sender, AjaxEventArgs e)
    *** {
    ******* if (!String.IsNullOrEmpty(this.TextField2.Text))
    ******* {
    *********** this.TextField3.Text = this.TextField2.Text;
    ******* }
    ******* this.Label1.Html = this.TextField2.Text + " test";
    *** }
    </script></p>
    
    
    <!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 id="Head1" runat="server">
    *** <title>HtmlEditor</title>
    </head>
    <body>
    *** <ext:scriptmanager id="ScriptManager1" runat="server" />
    *** <form id="Form1" runat="server">
    *** Field1 (Open): <ext:textfield id="TextField1" runat="server" />
    *** <br /><br />
    *** Field2 (Read Only): <ext:textfield id="TextField2" runat="server" readonly="true" />
    *** <br /><br />
    *** <ext:button id="Button1" runat="server" text="Copy Field1 to Field2">
    ******* <AjaxEvents>
    *********** <Click OnEvent="Button1_Click" />
    ******* </AjaxEvents>
    *** </ext:button>
    *** <br />
    *** <ext:button id="Button2" runat="server" text="Copy Field2 to Field3">
    ******* <AjaxEvents>
    *********** <Click OnEvent="Button2_Click" />
    ******* </AjaxEvents>
    *** </ext:button>
    *** <br />
    *** Field3 (Read Only): <ext:textfield id="TextField3" runat="server" readonly="true" />
    *** <br /><br />
    *** Label: <ext:label id="Label1" runat="server" />
    *** </form>
    </body>
    </html>
    Thanks again for everything. You guys rock!

    </p>
  6. #6

    RE: About TextField Attribute Question

    I found the answer!

    http://forums.ext.net/showthread.php?1818#post7908

    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    
    <script runat="server">
        protected void Button1_Click(object sender, AjaxEventArgs e)
        {
            this.TextField2.Text = this.TextField1.Text;
            
            if (!String.IsNullOrEmpty(this.TextField2.Text))
            {
                this.Label1.Html = this.TextField2.Text;
            }
        }
        
        protected void Button2_Click(object sender, AjaxEventArgs e)
        {
            if (!String.IsNullOrEmpty(this.TextField2.Text))
            {
                this.TextField3.Text = this.TextField2.Text;
            }
            this.Label1.Html = this.TextField2.Text + " test";
        }
    </script>
    
    <!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 id="Head1" runat="server">
        <title>HtmlEditor</title>
    </head>
    <body>
        <ext:scriptmanager id="ScriptManager1" runat="server" />
        <form id="Form1" runat="server">
        Field1 (Open): <ext:textfield id="TextField1" runat="server" />
        <br /><br />
        Field2 (Read Only): <ext:textfield id="TextField2" runat="server" readonly="true" />
        <br /><br />
        <ext:button id="Button1" runat="server" text="Copy Field1 to Field2">
            <AjaxEvents>
                <Click ViewStateMode="Include"  OnEvent="Button1_Click" />
            </AjaxEvents>
        </ext:button>
        <br />
        <ext:button id="Button2" runat="server" text="Copy Field2 to Field3">
            <AjaxEvents>
                <Click OnEvent="Button2_Click" />
            </AjaxEvents>
        </ext:button>
        <br />
        Field3 (Read Only): <ext:textfield id="TextField3" runat="server" readonly="true" />
        <br /><br />
        Label: <ext:label id="Label1" runat="server" />
        </form>
    </body>
    </html>
    Thanks Vlad!
    Last edited by geoffrey.mcgill; Feb 21, 2011 at 9:08 PM.

Similar Threads

  1. ClientConfig Attribute
    By PerfectElement in forum 1.x Help
    Replies: 6
    Last Post: Nov 11, 2011, 4:50 PM
  2. [CLOSED] triggerfield / textfield question
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 1
    Last Post: Sep 29, 2010, 5:02 PM
  3. ServerMapping with more attribute
    By Maia in forum 1.x Help
    Replies: 3
    Last Post: Aug 12, 2010, 4:48 PM
  4. [1.0] layouts attribute
    By [WP]joju in forum 1.x Help
    Replies: 2
    Last Post: Nov 12, 2009, 1:41 AM
  5. TextField Question
    By davidhoyt in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Jan 12, 2009, 6:04 PM

Posting Permissions