Custom Error from StoreFile()

5 posts, 0 answers
  1. Chris
    Chris avatar
    20 posts
    Member since:
    Jan 2009

    Posted 29 May 2009 Link to this post

    In my Custom ContentProvider, is there a way to return an error string from StoreFile()?
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 01 Jun 2009 Link to this post

    Hi Chris,

    The StoreFile function returns the path to the stored item and we do not recommend you replace that behavior. Could you please provide more details on what exactly you want to achieve?



    Sincerely yours,
    Fiko
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Adam
    Adam avatar
    177 posts
    Member since:
    Oct 2012

    Posted 19 Jul 2011 Link to this post

    I also have a need for this. We are using the custom file provider example to allow people to have access to their home directory when they are not on site. However, they have a limited amount of space. When they hit their space limit, I'd like to report a nice message instead of it just throwing an exception. The exception that is being caused when they run out of space is: There is not enough space on the disk.
  5. juan
    juan avatar
    3 posts
    Member since:
    Oct 2007

    Posted 21 Jul 2011 Link to this post

    i have the same problem,  i want to verify if i have space in the hard disk when the users upload files or the extension file using my code. Who is posible to verify this and put the message in the frontend?
    Thanks.
  6. Dobromir
    Admin
    Dobromir avatar
    1633 posts

    Posted 22 Jul 2011 Link to this post

    Hi guys,

    To achieve the required functionality you can override the StoreFile() method of the content provider, handle the exception and use the ScriptManager.RegisterStartupScript() to display an alert with the custom message. You can get reference to the Page object from the content provider using the following code:
    var page = HttpContext.Current.Handler as Page;

    The following is a sample StoreFile() method that pop-ups an alert:
    public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)
    {
        try
        {
            throw new IOException("Forced Exception");
        }
        catch (IOException e)
        {
            var page = HttpContext.Current.Handler as Page;
     
            ScriptManager.RegisterStartupScript(page, page.GetType(), "key", @"alert(""Custom Error Message!"");", true);
        }
     
        return base.StoreFile(file, path, name, arguments);
    }

    I hope this helps.

    Regards,
    Dobromir
    the Telerik team

    Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Back to Top
UI for ASP.NET Ajax is Ready for VS 2017