How can I send the whole asyncuploadcontrol to a webmethod for handling?

2 posts, 1 answers
  1. Jeremy
    Jeremy avatar
    14 posts
    Member since:
    Mar 2012

    Posted 07 Apr 2012 Link to this post

    My implementation prevents me from using the traditional OnFileUploaded event since there are several instances of this control and each needs to be tied to a ticketID that is contained in a hidden field. I was able to get a reference to the uploader object that is relevant to the button that fired the event like this:

    $(".SubmitFiles").click(function () {
           var uplodrID = $(this).closest(".AddAttachment").find(".Uploader").attr("ID");
           var upldrObj = $find(uplodrID); //this is the telerik asyncupload control
       });

    At least, I'm pretty sure it is because I can see all of the relevent settings and such inside of it during debug. Now, what I want to do is send this control into a webmethod in the page codebehind so that I can interate through all the files and send them to a database. I tried to do so like this:

    PageMethods.ProcessUpload(upldrObj);

    And of course I enabled pagemethods in the ScriptManager. What is happening is ...well nothing. The page doesn't throw and error, but its also  not showing that it is actually getting through to the webmethod. I set the webmethod to throw an exception if it ever got that far, but it never does. When I step through debug, the debug finishes before it ever gets to the webmethod:

    [WebMethod()]
    public static void ProcessUpload(RadAsyncUpload upld)
    {
        throw new Exception("Stub");
    }

    Can anyone help? I'm sure I'm missing something minor
  2. Answer
    Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 12 Apr 2012 Link to this post

    Hello Jeremy,

    What you are trying to do is not possible. Page Methods are static and no instance of control can live there. You may want to check this article for more information.

     

    Kind regards,
    Genady Sergeev
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Back to Top