Upload with Ajax

2 posts, 0 answers
  1. shahab
    shahab avatar
    22 posts
    Member since:
    Oct 2012

    Posted 14 Dec 2008 Link to this post

    Hi everyone,
    I have a scenario where I insert just the filename of the file I upload in the database. For this I upload a file to the server and retrieve the filename and then save the entity. But if I  set the AjaxControlID="btnSave" I get en error saying object reference.
    below is the code:

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="LoadingPanel1">  
               <telerik:AjaxSetting AjaxControlID="btnSave">  
                        <telerik:AjaxUpdatedControl ControlID="lblInfo" /> 


    <form id="form1" runat="server">


    <asp:label id="lblInfo" runat="server"/>

    asp:FileUpload ID="image" runat="server" />



    <asp:Button ID="btnSave" runat="server" Text="Save"



    onclick="btnSave_Click" />



    and in the code behind I have the following:

    private String GetUploadImageName()  
            if (image.PostedFile.ContentLength > 0)  
                //upload the file  
                image.PostedFile.SaveAs(Server.MapPath("~\\Resources\\Images\\ExcerciseImages\\" +  
                        txtName.Text.ToString() + ".jpg"));  
                return txtName.Text.ToString() + ".jpg";  
                return "";  

    If anyone could help me point in the correct direction that be great.
  2. Vlad
    Vlad avatar
    11100 posts

    Posted 15 Dec 2008 Link to this post

    Hello shahab,

    Please check this demo for more info:

    Best wishes,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top