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

RadBinary Image control

10 Answers 146 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Chom
Top achievements
Rank 1
Chom asked on 18 Feb 2010, 04:47 AM
Hi all

I want to use the RadBinary image control in my app but I cannot find anything on how to limit the size of the file to be uploaded.

what I need to do is limit the size of images to be uploaded to less than 5mb.

Has anyone had any experience with this?

Thanks

chommy

10 Answers, 1 is accepted

Sort by
0
robertw102
Top achievements
Rank 1
answered on 18 Feb 2010, 02:39 PM
The RadBinary control is not used for uploading images, but for displaying images from the database. If you want to limit the file size of uploaded files you would use the RadUpload control and set the MaxFileSize to 5MB. The MaxFileSize is entered in bytes so you'll need to find that out.

I hope that helps.
0
Chom
Top achievements
Rank 1
answered on 18 Feb 2010, 04:07 PM
Thanks for that info on the upload control.

 I was looking more at the BinaryImage/ Binary Images and Upload in Grid demo:
http://demos.telerik.com/aspnet-ajax/controls/examples/integration/raduploadinajaxifiedgrid/defaultcs.aspx?product=binaryimage
to see if there is a way to limit file size. I see that there is a radupload control in the edit mode of the grid, but I cannot figure out how to get to it.

0
robertw102
Top achievements
Rank 1
answered on 18 Feb 2010, 08:11 PM
Sorry about that. The way to access the RadUpload control used in edit mode for the RadBinaryColumn is to handle the ItemCreated event of the RadGrid control. In the demo you provided they show the way to access the RadUpload control, so if so look at the code-behind of the demo page, they handle the ItemCreated event and the RadUpload control used by the editor is called RadUploadControl. So you should be able to set the MaxFileSize for the RadUploadControl in that event.

Below is the event I mention and how to access the RadUploadControl:

protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridEditableItem && e.Item.IsInEditMode) 
            { 
                GridBinaryImageColumnEditor editor = ((GridEditableItem)e.Item).EditManager.GetColumnEditor("Upload"as GridBinaryImageColumnEditor; 
                TableCell cell = (TableCell)editor.RadUploadControl.Parent; 
                CustomValidator validator = new CustomValidator();  
                validator.ErrorMessage = "Please select file to be uploaded"
                validator.ClientValidationFunction = "validateRadUpload"
                validator.Display = ValidatorDisplay.Dynamic; 
                cell.Controls.Add(validator); 
            } 
        } 


I hope that helps.
0
Chom
Top achievements
Rank 1
answered on 19 Feb 2010, 06:35 PM
Thanks for your help.

I got it figured.
0
Clayton
Top achievements
Rank 1
answered on 01 Aug 2010, 03:25 AM
I have tried the above method, and the upload control still does not limit filesize in any way.

What am I missing?

If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
    Dim editor As GridBinaryImageColumnEditor = TryCast(DirectCast(e.Item, GridEditableItem).EditManager.GetColumnEditor("Upload"), GridBinaryImageColumnEditor)
    editor.RadUploadControl.MaxFileSize = 1024
 
End If
0
Nikolay Rusev
Telerik team
answered on 05 Aug 2010, 11:12 AM
Hello Clayton,

Bellow link explains in details how to control uploaded files content size:
http://www.telerik.com/help/aspnet-ajax/upload_uploadinglargefiles.html

Regards,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Clayton
Top achievements
Rank 1
answered on 05 Aug 2010, 04:07 PM
Hello Nikolay,
I do not understand how to apply this setting to something like a Radbinary image control in a grid. How can I access the radupload control inside of that?
0
Nikolay Rusev
Telerik team
answered on 11 Aug 2010, 07:27 AM
Hello Clayton,

There seems to be a bug introduced with latest version of RadGrid. Setting the properties as in your previous post should be working correctly. However the validation for size will fail and will not prevent file from being uploaded.

We will need some more time to investigate this behavior. I will update this post as soon as fix is provided.

All the best,
Nikolay
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Milind Raje
Top achievements
Rank 1
answered on 19 Nov 2010, 07:53 PM
How does one display an image from the database in free format instead of a grid? The GridBinaryImageColumn is available only in RadGrid.
thanks
milind
0
Nikolay Rusev
Telerik team
answered on 22 Nov 2010, 08:42 AM
Milind Raje,

You can use RadBinaryImage as separate control. For more details please check the ItemTemplate of following demo:
http://demos.telerik.com/aspnet-ajax/binaryimage/examples/default/defaultcs.aspx

Regards,
Nikolay
the Telerik team
Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
Tags
Ajax
Asked by
Chom
Top achievements
Rank 1
Answers by
robertw102
Top achievements
Rank 1
Chom
Top achievements
Rank 1
Clayton
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Milind Raje
Top achievements
Rank 1
Share this question
or