A couple questions

Nov 18, 2009 at 8:06 PM

Hi, I had a couple questions.

1) is there a way to send a postback on a textbox when you click the enter button (such as onkeypress)?

2) is there a way to NOT have the cancel confirm box come up when a form control has changed within a Window popup?

3) is there a way to have a longer execution time on postbacks before a "current page request failed!" message is displayed? Some of my postbacks take a bit to process data...

Thanks and I appriciate the time to answer!

Jamie

Coordinator
Nov 19, 2009 at 12:51 PM

1. You can achieve this by custom Javascript, but the textbox doesn't has the server event handler to handle this postback. So you should write your code in Page_Load.

2. Yes. Window2.OnClientCloseButtonClick = Window2.GetCloseReference();

By default, this value is GetConfirmFormModifiedCloseReference();

3. The default ajax timeout is 30s.

You can overwrite this config in Javascript:

Ext.Ajax.timeout = 60 * 1000;  // 60s

Nov 19, 2009 at 1:29 PM

Thanks Sanshi! You are such a fast and great help! Thx!

Coordinator
Nov 19, 2009 at 1:31 PM

Pleasure to hear from you.

And I am writing an example to answer your first question.

 

Coordinator
Nov 19, 2009 at 1:35 PM

1) is there a way to send a postback on a textbox when you click the enter button (such as onkeypress)?

-----.ASPX:

<ext:PageManager ID="PageManager1" runat="server" />
    <ext:SimpleForm ID="SimpleForm1" runat="server" Width="600px" BodyPadding="5px" EnableBackgroundColor="true"
        Title="SimpleForm">
        <Items>
            <ext:TextBox ID="TextBox1" runat="server" Label="Label" EmptyText="Input some text and press ENTER key, see the result." Text="">
            </ext:TextBox>
            <ext:TextBox ID="TextBox2" runat="server" Label="Label" Text="">
            </ext:TextBox>
            <ext:Button ID="Button1" runat="server" Text="Button">
            </ext:Button>
        </Items>
    </ext:SimpleForm>

    <script type="text/javascript">

        function onReady() {
            var textbox1ID = '<%= TextBox1.ClientID %>';
            var textbox1 = Ext.getCmp(textbox1ID);
            textbox1.on("specialkey", function(box, e) {
                if (e.getKey() == e.ENTER) {
                    __doPostBack(textbox1ID, 'specialkey');
                }
            });
        }
    
    </script>


--------.CS:

protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

            }
            else
            {
                if (Request.Form["__EVENTTARGET"] == TextBox1.ClientID && Request.Form["__EVENTARGUMENT"] == "specialkey")
                {
                    TextBox2.Text = TextBox1.Text;
                    TextBox2.Focus(true, 100);
                }
            }
        }

Nov 19, 2009 at 5:36 PM

Wow! Thanks so much. I need to put you on my Christmas Gift list

Feb 13, 2011 at 4:59 AM

hi sanshi:

I would the Textbox changed to the TextArea , but it's don't work. why?

 <script type="text/javascript">

        function onReady() {
            var TextArea1ID = '<%= TextArea1.ClientID %>';
            var TextArea1 = Ext.getCmp(TextArea1ID);
            TextArea1.on("specialkey", function(box, e) {
                if (e.getKey() == e.ENTER) {
                    __doPostBack(TextArea1ID, 'specialkey');
                }
            });
        }
   
    </script>

 

Coordinator
Feb 22, 2011 at 1:46 PM

Maybe ENTER is not a special key in TextArea, I guess.  It's used to create a new line. Then you should refer to the extjs document.