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

upload and ajax

7 Answers 378 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
mansour
Top achievements
Rank 2
mansour asked on 13 Mar 2008, 01:26 PM
Hello,
  Is there any simple demo that shows how to turn off the ajax when using upload?

I found a demo in demo project but as it is related to other pages, I can not figure out how it is working. What I want is a very simple project with only one page that has only an ajax panel and an upload. Is there any such demo?

Regards

7 Answers, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 13 Mar 2008, 01:37 PM
Hello Mansour,

I suggest you take a look at the Uploading Files with Ajax help article which contains detailed information on the issue and provides simple code snippets which demonstrate the suggested workarounds.

Please, let us know if you need further assistance.

Best regards,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
mansour
Top achievements
Rank 2
answered on 13 Mar 2008, 03:54 PM
Thanks for your reply.
I created an ASP.NET ajax enabled page and I add a grid in it and then I tried to make it compatible with the sample on the page that you referenced. the aspx file is as follow:

<%

@ Page Language="C#" AutoEventWireup="true" Codebehind="Default.aspx.cs" Inherits="TestGridUpload._Default" %>

<%

@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!

DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<

html xmlns="http://www.w3.org/1999/xhtml">

<

head runat="server">

<title>Untitled Page</title>

</

head>

<

body>

<

script type="text/javascript">

//on insert and update buttons click temporarily disables ajax to perform upload actions

function

conditionalPostback(e, sender)

{

var re = new RegExp("\.UpdateButton$|\.PerformInsertButton$", "ig");

if (sender.EventTarget.match(re))

{

sender.EnableAjax =

false;

}

}

</

script>

<form id="form1" runat="server">

<asp:ScriptManager ID="ScriptManager1" runat="server" />

<div>

<telerik:RadGrid ID="RadGrid1" runat="server" enableajax="true">

<ClientSettings>

<ClientEvents onrequeststart="conditionalPostback" />

</ClientSettings>

</telerik:RadGrid>

</div>

</form>

</

body>

</

html>

but I am getting the following error:

 Generation of designer file failed: Type 'Telerik.Web.UI.GridClientEvents' does not have a public property named 'onrequeststart'. 

Validation (ASP.Net): Attribute 'enableajax' is not a valid attribute of element 'RadGrid'. 

Validation (ASP.Net): Attribute 'onrequeststart' is not a valid attribute of element 'ClientEvents'.

Can you please help me to find the problem?

Best regards

0
mansour
Top achievements
Rank 2
answered on 13 Mar 2008, 05:12 PM

Hello,

    I created a new page. The declarations in the page is as follow:

 

<%@ Page Language="C#" AutoEventWireup="true" Codebehind="UploadAjax.aspx.cs" Inherits="TestGridUpload.UploadAjax" %>

 

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

    <title>Untitled Page</title>

</head>

<body>

    <form id="form1" runat="server">

   

        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">

       

        </telerik:RadScriptManager>

        <RadScriptBlock ID="RadScriptBlock1" runat="server">

         <script type="text/javascript">

//on upload button click temporarily disables ajax to perform upload

//actions

        function conditionalPostback(sender, args)

{

   if(args.EventTarget == "<%= ButtonSubmit.UniqueID %>")

   {

   args.EnableAjax = false;

   }

}

            </script>

       

</RadScriptBlock>

        <div>

 

          

 

 

            <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1" ClientEvents-OnRequestStart="conditionalPostback">

           

                <telerik:RadUpload ID="RadUpload1" runat="server" Skin="Office2007" InitialFileInputsCount="1"

                        TargetFolder="~/UploadTemp" AllowedFileExtensions=".srd" Width="100%" InputSize="110" ControlObjectsVisibility="ClearButtons"/>

                <asp:Button ID="ButtonSubmit" runat="server" Text="Upload" />

            </telerik:RadAjaxPanel>

        </div>

    </form>

</body>

</html>

 

I have two error in the page that I can not understand why I have them.

 

Validation (Internet Explorer 6): Element 'radscriptblock' is not supported.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\UploadAjax.aspx 15           10                TestGridUpload

 

Element 'RadUpload' is not a known element. This can occur if there is a compilation error in the Web site.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\UploadAjax.aspx 36           26                TestGridUpload

 

When I run the application, the upload doesn’t work and no file is transferred after I pressed upload button.

 

Any help is very appreciated.

 

Regards

0
Sophy
Telerik team
answered on 14 Mar 2008, 09:43 AM
Hello Mansour,

The problem you describe in the first post is due to the fact that you use the suggested workaround for RadGrid Classic but replace the grid with RadGrid "Prometheus".  RadGrid "Prometheus" does not support integrated Ajax. That i why you should either use RadAjaxPanel or RadAjaxManager which provide the same  OnRequestStart client-side event, e.g:

<radscriptblock id="RadScriptBlock1" runat="server">  
 <script type="text/javascript">  
  //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 = $find(window['UploadId']);  
      //AJAX is disabled only if file is selected for upload  
      if(upload.getFileInputs()[0].value != "")  
      {  
        sender.EnableAjax = false;  
      }  
    }  
  }  
 </script> 
</radscriptblock> 
 
</script>   
<telerik:radajaxpanel id="RadAjaxPanel1" runat="server" clientevents-onrequeststart="conditionalPostback">  
 <telerik:radprogressmanager id="RadProgressManager1" runat="server"/>  
 <telerik:radgrid runat="server" id="RadGrid1" enableajax="true">   
        <mastertableview>   
            <columns>   
                <telerik:grideditcommandcolumn />   
                <telerik:gridtemplatecolumn uniquename="Upload">   
                          <itemtemplate> ... </itemtemplate> 
                          <edititemtemplate>   
                               <telerik:radupload id="RadUpload1" runat="server" /> 
                          </edititemtemplate>   
                </telerik:gridtemplatecolumn>   
          </columns>   
          <editformsettings> 
                   <editcolumn uniquename="EditCommandColumn1"</editcolumn>   
          </editformsettings> 
       </mastertableview>   
 </telerik:radgrid> 
<telerik:radajaxpanel> 

Regarding the errors you mention in the second post they appear only in design time in Visual Studio. These errors should not cause problems when running the page and do not deserve special attention. I am not sure what may be the reason for selected files not being uploaded. Please, make sure that you upload a file with a .srd extension when it is not saved in the target folder. I tested with the same code and was not able to reproduce the issue. Could you please open a support ticket and send us a simple running application which reproduces the problem including all the files for testing it. As soon as we receive it we will test it locally and research the problem. For your convenience I have attached my testing page and the Web.config file so that you can take a look at them.

Best wishes,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
mansour
Top achievements
Rank 2
answered on 14 Mar 2008, 10:22 AM

Thanks Sophy,

 

I still has some problem!

 

I am including my test project for your information. There are some pages which I use for testing how I can use upload in different situations.

 

1-      Test1: I create this page using your code but I still I am getting the following errors:

Validation (Internet Explorer 6): Element 'radscriptblock' is not supported.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              11           10                TestGridUpload

Element 'radprogressmanager' is not a known element. This can occur if there is a compilation error in the Web site.       C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              30           22                TestGridUpload

Element 'radgrid' is not a known element. This can occur if there is a compilation error in the Web site.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              31           22                TestGridUpload

Validation (Internet Explorer 6): Element 'mastertableview' is not supported.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              32           18                TestGridUpload

Validation (Internet Explorer 6): Element 'columns' is not supported.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              33           14                TestGridUpload

Element 'grideditcommandcolumn' is not a known element. This can occur if there is a compilation error in the Web site.       C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              34           26                TestGridUpload

Element 'gridtemplatecolumn' is not a known element. This can occur if there is a compilation error in the Web site.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              35           26                TestGridUpload

Validation (Internet Explorer 6): Element 'itemtemplate' is not supported.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              36           28                TestGridUpload

Validation (Internet Explorer 6): Element 'edititemtemplate' is not supported.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              37           28                TestGridUpload

Element 'radupload' is not a known element. This can occur if there is a compilation error in the Web site.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              38           41                TestGridUpload

Validation (Internet Explorer 6): Element 'editformsettings' is not supported.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              42           12                TestGridUpload

Validation (Internet Explorer 6): Element 'editcolumn' is not supported.                C:\MyData\projects\DSL\test_applications\TestGridUpload\TestGridUpload\test1.aspx              43           21                TestGridUpload

 

2-      I like to use a window for uploading as shown in page UploadWindow. The problem that I have is as follow:

How can close the window when the upload is finished? I need to attach a post back to button1 in uploadfile page to control file uploads. I need to close the window at the end of file upload which is when the button1 post back is returning. What can I do?

 

 

Any help is very appreciated.

 

Regards

Mansour

ps: I can not find a way to upload my project. Could you please tell me how I can upload the sample project?

0
Sophy
Telerik team
answered on 14 Mar 2008, 11:46 AM
Hello Mansour,

Please, find my answers to your questions below:
  1. As I mentioned in my previous reply you should not pay attention to these errors. They are due to Visual Studio and appear only in design time. These errors will not confuse the proper functioning of the controls when running the page.
  2. Regarding your second question, please, send us your application so that we can get a better idea of the scenario you want to achieve and the problem you experience.

To send us your application you should open a support ticket as it is not allowed to attach files in forum posts. You can find attached a screenshot with instructions how to open a support ticket.

Kind regards,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
mansour
Top achievements
Rank 2
answered on 14 Mar 2008, 01:18 PM
Thanks Sophy,
   I created a support ticket (126954) and I attached my test project to it.

Best regards
Mansour
Tags
Upload (Obsolete)
Asked by
mansour
Top achievements
Rank 2
Answers by
Sophy
Telerik team
mansour
Top achievements
Rank 2
Share this question
or