This is a migrated thread and some comments may be shown as answers.

Upload with Ajax

1 Answer 47 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
shahab
Top achievements
Rank 1
shahab asked on 14 Dec 2008, 08:42 AM

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 

1 Answer, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 15 Dec 2008, 07:26 AM
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.
Tags
Ajax
Asked by
shahab
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Share this question
or