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">  
            <AjaxSettings> 
               <telerik:AjaxSetting AjaxControlID="btnSave">  
                  <UpdatedControls> 
                        <telerik:AjaxUpdatedControl ControlID="lblInfo" /> 
                  </UpdatedControls> 
              </telerik:AjaxSetting> 
            </AjaxSettings> 
    </telerik:RadAjaxManager> 

     

    <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" />

     

    </form>

    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";  
            }  
            else 
            {  
                return "";  
            }  
        } 

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

    Posted 15 Dec 2008 Link to this post

    Hello shahab,

    Please check this demo for more info:
    http://demos.telerik.com/aspnet-ajax/Controls/Examples/Integration/RadUploadInAjaxifiedGrid/DefaultCS.aspx?product=grid

    Best wishes,
    Vlad
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top