[OPEN] [#456] DirectEvents and FileUploadField

  1. #1

    [OPEN] [#456] DirectEvents and FileUploadField

    Hello,

    I have a lot of direct events and methods on the page in my project but after I added the file upload field on the page I had found that all directevents sends untypical posts.
    I know about specific posts when we use this type of field and I have seen similar problem in the post below

    http://forums.ext.net/showthread.php...leUpload-Issue

    But can I disable unusual ajax functionality for all direct events where it's unnecessary (OnChangeText event in example below) and enable it only for requests where I send file (OnPostFile)?

    I tried to set IsUpload to false for OnChangeText but it didn't affect on requests.

    Rough example
    <ext:TextField>
        <DirectEvents>
            <Change OnEvent="OnChangeText" />
        </DirectEvents>
    </ext:TextField>
    
    <ext:FormPanel>
        <Items>
            <ext:FileUploadField>
            </ext:FileUploadField>
        </Items>
        <Buttons>
            <ext:Button Text="Send">
                <DirectEvents>
                    <Click OnEvent="OnPostFile" />
                </DirectEvents>
           </ext:Button>
        </Buttons>
    </ext:FormPanel>
    -Thanks
    Last edited by Daniil; Mar 19, 2014 at 11:16 AM. Reason: [OPEN] [#456]
  2. #2
    Hi @Yury,

    Maybe, a DirectEvent's Type="Load" setting is what you are looking for? It does not submit anything at all except ExtraParams.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi @Yury,

    Maybe, a DirectEvent's Type="Load" setting is what you are looking for? It does not submit anything at all except ExtraParams.
    Thank you for reply.

    I know about it, but I often use control state in direct events and I can't use Type="Load" for all requests.
    Now I know only one way - add form with file upload control to the iframe, but it isn't good way.

    I think should be another way, for example, special attribute which denote that the request should use standard ajax to submit data or request can post file (e.g. Type="SubmitFile")
  4. #4
    Agree, it would be good to have an option for that.

    For now I can suggest the following solution. Does it work for you?

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void OnChangeText(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("OnChangeText", "Hello from Server!").Show();
        }
    
        protected void OnPostFile(object sender, DirectEventArgs e)
        {
            X.Msg.Alert("OnPostFile", "Hello from Server!").Show();
        }
    </script>
    
    <!DOCTYPE html>
    <html>
    <head runat="server">
        <title>Ext.NET v2 Example</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <ext:ResourceManager runat="server" />
    
            <ext:TextField runat="server">
                <DirectEvents>
                    <Change 
                        OnEvent="OnChangeText" 
                        Before="Ext.getDom('form1').removeAttribute('enctype');"
                        After="Ext.getDom('form1').setAttribute('enctype', 'multipart/form-data');" />
                </DirectEvents>
            </ext:TextField>
    
            <ext:FormPanel runat="server">
                <Items>
                    <ext:FileUploadField runat="server" />
                </Items>
                <Buttons>
                    <ext:Button runat="server" Text="Send">
                        <DirectEvents>
                            <Click OnEvent="OnPostFile" />
                        </DirectEvents>
                    </ext:Button>
                </Buttons>
            </ext:FormPanel>
        </form>
    </body>
    </html>
  5. #5
    Thank you, Daniil.

    It works for me, but what about something special for direct events/methods? Are you going to investigate this feature?

    Yury
  6. #6
  7. #7
    Thank you, Daniil
  8. #8
    Hello, Daniil.

    Is there any progress?
  9. #9
    Unfortunately, no. I don't think that it will appear in v2.x. at all. Hopefully we will be able to get it working for v3.x.

Similar Threads

  1. Replies: 10
    Last Post: Jan 30, 2014, 11:42 PM
  2. [CLOSED] GridPanel DirectEvents - FileUploadField error
    By Aurelio in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: Mar 16, 2012, 12:52 PM
  3. Replies: 6
    Last Post: Jan 11, 2012, 9:52 AM
  4. DirectEvents get queued.
    By jorge2esteban in forum 1.x Help
    Replies: 4
    Last Post: Oct 25, 2011, 1:54 PM
  5. Not Find 'DirectEvents'
    By sindevil0010 in forum 1.x Help
    Replies: 2
    Last Post: Aug 12, 2010, 2:36 AM

Posting Permissions