Article relates to
|
RadUpload
RadGrid
RadComboBox
|
.NET version |
2.0, 3.5 and later
|
Visual Studio version |
2005, 2008 and later
|
programming language |
C#, VB
|
browser support |
all browsers supported by RadControls
|
PROJECT DESCRIPTION
The attached project demonstrates how to integrate RadUpload in RadGrid to upload images and edit the image information. RadGrid is set to work in AJAX mode by setting its EnableAJAX property to True. However, since RadUpload can upload files only on full postback, when a new file needs to be uploaded(clicking Insert or Update button in a row's edit template) the AJAX is being temporally disabled. This is achieved by handling RadGrid's client event OnRequestStart and setting grid's EnableAJAX to false:
//on insert and update buttons click temporarily disables ajax to perform upload actions |
function conditionalPostback(e, sender) |
{ |
var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig"); |
if (sender.EventTarget.match(theRegexp)) |
{ |
var upload = window['UploadId']; |
|
//AJAX is disabled only if file is selected for upload |
if(upload.GetFileInputs()[0].value != "") |
{ |
sender.EnableAjax = false; |
} |
} |
} |
This method also checks whether a file has been selected for upload and if not AJAX is not being disabled.
Image and thumbnail files are saved in a folder, information about them including the folder path is saved in a database with server-side code. RadComboBox with template rows is used to edit the author name information.
UPDATED VERSION BELOW
Since RadUpload cannot upload files using AJAX calls (this is a limitation of the XmlHttpRequest component, used in all AJAX frameworks for asynchronous calls to the application), in order to upload a file you should perform a full page postback.
If you have button or other control, which normally does postbacks, placed in a RadGrid which is inside a RadAjaxPanel or the RadGrid is ajaxified by RadAjaxManager, you need to attach an event handler on the OnRequestStart client-side event of the RadAjaxPanel or RadAjaxManager, which will disable the AJAX functionality by
e.set_enableAjax(false) function. You can also perform validation over the file input as shown in the code library demo code: