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