Page still reloads?

Last post 05-25-2009, 11:24 AM by cutechat. 4 replies.
Sort Posts: Previous Next
  •  05-22-2009, 10:04 AM 52428

    Page still reloads?

    Hi!
     
    Please excuse me for my poor knowledge regarding web development and asp.net but I´m wondering if, when using the AjaxUploader, the page really should get reloaded after each added attachment? I have a multiple attachment control and each time I add an attachment a page load occurs. Is this the behavior even when using Ajax?
     
    Thanks!
     
    Regards,
     
    Niclas 
  •  05-22-2009, 12:19 PM 52431 in reply to 52428

    Re: Page still reloads?

  •  05-22-2009, 10:41 PM 52438 in reply to 52428

    Re: Page still reloads?

    Niclas 
     
    What do you mean using Ajax ?
     
    If you are using Microsoft AJAX , it will send a request to server , and change the content of the page.
     
    If you use other client side AJAX , such as raw XMLHttpRequest code , you need catch the event and return false :
     
    <script>
    function CuteWebUI_AjaxUploader_OnPostBack()
    {
            return false;
    }
    </script>
     
    Regards,
    Terry
     
  •  05-25-2009, 12:58 AM 52449 in reply to 52438

    Re: Page still reloads?

    Adam, cutechat, thanks for your replys!
     
    OK, so I see. But suppose I use Microsoft AJAX and sending a server request is ok performance wise but I need to distinguish the event generated by the file upload from other events that causes post back so that I can direct my code behind depending on which control that is causing the post back, how do I manage that? The "IsPostBack" property is "not enough" so to speak, I need to know which control is "throwing" the event so that I can act accordingly directly when "Page_Load" occurs. Can I do that?
     
    When I have added a "protected void UploadAttachments1_AttachmentAdded(object sender, CuteWebUI.AttachmentItemEventArgs args)" event handler to my code behind this event is catched after the "Page_Load" and because I have code in the "Page_Load" that I dont want to execute when a file upload occurs I would somehow to know that it is the file upload that has caused the new "Page_Load".
     
    As you see I don't know anything about asp.net but I would highly appreciate any answer to this "generic" asp.net functionality question.
     
     
    EDIT: Achieved the desired functionality using:
     
                string ctrlname = Page.Request.Params.Get("__EVENTTARGET");
                if (ctrlname != null && ctrlname.Equals("UploadAttachments1"))
                {
                    return;
                }
     
     Thanks!

    Regards,
     
    Niclas
     

     
     
  •  05-25-2009, 11:24 AM 52481 in reply to 52449

    Re: Page still reloads?

    Hi,
     
    Yes. the Page.Load event will fired when the uploader want to fire the FileValidating event.
     
    Regards,
    Terry
View as RSS news feed in XML