I have panel to contain all body
then i use ajax to control this panel
Code show below
I have a uploader inside the pnlMainCat
when i upload file, it cannot find the find
i use radupload.UploadedFiles.Count , it always give me 0
when i remove ajax, it can work properly
Demo
I tried this demo , but it cant work
then i use ajax to control this panel
Code show below
<
telerik:RadAjaxManagerProxy
ID
=
"RadAjaxManagerProxy1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"rblCatLevel"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"pnlMainCat"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"rblCatLevel"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManagerProxy
>
when i upload file, it cannot find the find
i use radupload.UploadedFiles.Count , it always give me 0
when i remove ajax, it can work properly
<
telerik:RadUpload
ID
=
"ruBanner"
runat
=
"server"
EnableAjaxSkinRendering
=
"true"
EnableFileInputSkinning
=
"false"
Width
=
"50%"
InitialFileInputsCount
=
"1"
ControlObjectsVisibility
=
"None"
/>
Demo
I tried this demo , but it cant work
5 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 16 Aug 2011, 09:02 AM
Hello Ying,
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 your application must perform a full page postback.
Check out the following help article for more on this.
Uploading FIles with AJAX.
Thanks,
Shinu.
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 your application must perform a full page postback.
Check out the following help article for more on this.
Uploading FIles with AJAX.
Thanks,
Shinu.
0
Rayne
Top achievements
Rank 1
answered on 25 Oct 2011, 09:35 PM
My page is using the RadAjaxManager. I've followed the suggestion to disable ajax on button click. I can run through the code, and always both InvalidFiles and UploadedFiles count is 0. I then added client-side validation for extensions. And when I click submit, I get back my validation error message about invalid extension. This is while trying to add a .jpg file. Not sure what I'm doing wrong.
What my page is doing is getting information from the user, including up to 10 image files. Then in my submit button code, I'm using that information to create an EF entity graph (detail record with a collection of photos) and saving it to a database.
What my page is doing is getting information from the user, including up to 10 image files. Then in my submit button code, I'm using that information to create an EF entity graph (detail record with a collection of photos) and saving it to a database.
<
telerik:RadAjaxManager
runat
=
"server"
ID
=
"RadAjaxManager1"
ClientEvents-OnRequestStart
=
"conditionalPostback"
> .... </
telerik:RadAjaxManager
>
<
telerik:RadUpload
ID
=
"RadUpload1"
runat
=
"server"
InitialFileInputsCount
=
"1"
MaxFileInputsCount
=
"10"
AllowedFileExtensions
=
".jpg,.gif,.jpeg,.png"
Skin
=
"Simple"
ReadOnlyFileInputs
=
"true"
/>
<
br
/>
<
asp:CustomValidator
runat
=
"server"
ID
=
"ExtensionValidations"
Display
=
"Dynamic"
ClientValidationFunction
=
"validateRadUpload1"
ErrorMessage
=
"Invalid file extension"
OnServerValidate
=
"ServerValidateExtensions"
/>
<
telerik:RadScriptBlock
runat
=
"server"
>
<
script
type
=
"text/javascript"
>
// on upload button click temporarily disables ajax to perform
// upload actions
function conditionalPostback(sender, args) {
if (args.get_eventTarget() == "<%= SubmitButton.UniqueID %>") {
args.set_enableAjax(false);
}
}
function validateRadUpload1(source, arguments) {
arguments.IsValid = $find("<%= RadUpload1.ClientID %>").validateExtensions();
}
</
script
>
</
telerik:RadScriptBlock
>
0
Hello Rayne,
Please provide the server-side code that you are using.
All the best,
Dimitar Terziev
the Telerik team
Please provide the server-side code that you are using.
All the best,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Rayne
Top achievements
Rank 1
answered on 28 Oct 2011, 01:36 PM
The server validation is the same as in the docs:
My other code is in the button click...it creates a new entity, populates it with the values from the form fields. then calls a method to get the images.
That method is here (also following the info in the docs):
When I break on the foreach and check the count of the collection (UploadedFiles), it's always 0.
There's only one part of my page that needs ajax so would it help to put that part in an ajaxpanel, instead of using the ajaxmanager? The rest of the page would be outside of the ajax panel, including the radupload and the submit button.
public
void
ServerValidateExtensions(
object
source, ServerValidateEventArgs e)
{
e.IsValid = (RadUpload1.InvalidFiles.Count == 0);
}
My other code is in the button click...it creates a new entity, populates it with the values from the form fields. then calls a method to get the images.
That method is here (also following the info in the docs):
private
void
MergePhotos(Submission sub)
{
foreach
(UploadedFile file
in
RadUpload1.UploadedFiles)
{
byte
[] bytes =
new
byte
[file.ContentLength];
file.InputStream.Read(bytes, 0, file.ContentLength);
Model.Photo p =
new
Model.Photo();
p.FileName = file.GetName();
p.Contents = bytes;
sub.Photos.Add(p);
}
}
There's only one part of my page that needs ajax so would it help to put that part in an ajaxpanel, instead of using the ajaxmanager? The rest of the page would be outside of the ajax panel, including the radupload and the submit button.
0
Rayne
Top achievements
Rank 1
answered on 31 Oct 2011, 04:41 PM
I got it to work finally.