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

RadUpload in WebUserControl Radgrid

9 Answers 253 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
sircutbreaker
Top achievements
Rank 1
sircutbreaker asked on 26 Sep 2009, 01:19 PM
I have a radgrid that uses a usercontrol for its edit form... I have the progress area and the manager on the page with the grid.

The form works fine as long as i dont place a file in the upload control... but if i select a file, when i press the insert button, the page comes with an: internet explorer cannot display the web page...
if i use firefox:
I get this err: The connection was reset
The connection to the server was reset while the page was loading.

How can I get the radupload with progress area to work in a webusercontrol inside of a radgrid ?

Any help would be appreciated

Jeff



9 Answers, 1 is accepted

Sort by
0
sircutbreaker
Top achievements
Rank 1
answered on 26 Sep 2009, 01:49 PM
Nevermind.. the file was too large.. httpruntime fixed it..
0
Accepted
Genady Sergeev
Telerik team
answered on 26 Sep 2009, 01:50 PM
Hi sircutbreaker,

This problem occurs because the default value for the maxRequestLength parameter in the section of the Machine.config file is 4096 (4 megabytes). As a result, files that are larger than this value are not uploaded by default. Hence the browser displays a not found page. Detailed help topic on how to increase the maximum page size can be found here.

All the best,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
sircutbreaker
Top achievements
Rank 1
answered on 26 Sep 2009, 02:16 PM
Ok... but now i have this issue...

the upload progress bar doesnt work if i place it in the ascx...

i can place it on the masterpage.. but since i am using a usercontrol with popupmode and modal enabled... the progress bar works behind the modal screen...

what to do? :)

Jeff
0
Genady Sergeev
Telerik team
answered on 28 Sep 2009, 12:39 PM
Hello sircutbreaker,

You need to have both RadProgressManager and RadProgressArea in the same aspx/ascx page in order to successfully monitor file uploads. Try moving the 3 upload components (RadUpload, RadProgressArea and RadProgressManager) to your user control. Does the issue persist?

Sincerely yours,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Bruno
Top achievements
Rank 2
answered on 09 Nov 2009, 06:36 AM
I am having trouble getting this to work. I have an aspx page with a RadGrid, and have a UserControl as it's edit form. The UserControl has a RadUpload and a button so the user can upload an image which is stored in a session variable. Once the rest of the form is complete, the form data and session variable are saved to the database.

There are 2 issues:

1) The UploadedFiles property on the RadUpload is empty when the user clicks the image submit button

2) How to get the ClientID of the image button (inside the user control) to disable AJAX?

ASPX page:

<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="conditionalPostback" >   
    <telerik:RadGrid ID="EntitiesGrid" runat="server">  
        <EditFormSettings EditFormType="WebUserControl" UserControlName="controls/Entity.ascx">  
 


        function conditionalPostback(sender, args)   
        {   
           if(args.EventTarget == 'how to get ClientID of button after the user control has loaded???')   
           {  
               args.EnableAjax = false;   
           }   
        } 

User Control:
<telerik:RadBinaryImage ID="LogoImage" runat="server" /><br /> 
<telerik:RadProgressManager ID="Radprogressmanager1" runat="server" /> <br /> 
<telerik:RadProgressArea id="progressArea1" runat="server" /><br /> 
<telerik:RadUpload ID="RadUpload1" runat="server" MaxFileInputsCount="1" InitialFileInputsCount="1" ControlObjectsVisibility="None" /> 
<asp:Button id="UploadSubmit" runat="server" OnClick="buttonSubmit_Click" text="Upload" CausesValidation="false" /> 

Note: A different button is used to submit the rest of the form data.

protected void buttonSubmit_Click(object sender, System.EventArgs e)  
{  
    if (RadUpload1.UploadedFiles.Count > 0)  
    {  
        // Store data is Session variable.... never reaches here as Count is 0  
    }  
}  
 

This was working when the RadUpload was directly inside an ASPX page. Now that it has moved to the user control inside the RadGrid it has stopped working.

Regards.
0
Genady Sergeev
Telerik team
answered on 12 Nov 2009, 08:09 PM
Hi Bruno,

You can refer to this help article for detailed explanation on how to achieve your target. The point of interest is "Workaround for RadGrid for ASP.NET AJAX". I hope this will help you to get started.

Kind regards,
Genady Sergeev
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Bruno
Top achievements
Rank 2
answered on 20 Nov 2009, 06:35 AM

Based on that article, here are the changes to get it working when the Upload is inside a user control

aspx

    <telerik:radscriptblock id="RadScriptBlock1" runat="server">  
        <script type="text/javascript">  
         //On insert and update buttons click temporarily disables ajax to perform upload actions  
         function conditionalPostback(sender, args)  
         {  
          var theRegexp = new RegExp("\.UpdateButton$|\.PerformInsertButton$|\.UploadSubmit$", "ig");  
            
          if (args.get_eventTarget().match(theRegexp))  
          {  
           var upload = $find(window['UploadId']);  
             
           //AJAX is disabled only if file is selected for upload  
           if(upload.getFileInputs()[0].value != "")  
           {  
             args.set_enableAjax(false);  
           }  
          }  
         }  
        </script> 
    </telerik:radscriptblock> 
      
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="conditionalPostback" >   
      
        <telerik:RadGrid   
                onitemdatabound="EntitiesGrid_ItemDataBound"   
         
             <EditFormSettings EditFormType="WebUserControl" UserControlName="controls/Entity.ascx" >

Inside the RegExp above, make sure you include any additional button name that is used to upload files, here we have an additional button called UploadSubmit inside the user control.

    protected void EntitiesGrid_ItemDataBound(object sender, GridItemEventArgs e)  
    {  
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
        {  
            UserControl userControl = (UserControl)e.Item.FindControl(GridEditFormItem.EditFormUserControlID);  
 
            RadUpload upload = userControl.FindControl("RadUpload1") as RadUpload;  
            RadAjaxPanel1.ResponseScripts.Add(string.Format("window['UploadId'] = '{0}';", upload.ClientID));  
        }  
    } 


ascx

<telerik:RadUpload ID="RadUpload1" runat="server" /> 
<asp:Button id="UploadSubmit" runat="server" OnClick="buttonSubmit_Click" text="Upload" 
    CausesValidation="false"  /> 

protected void buttonSubmit_Click(object sender, System.EventArgs e)  
{  
    if (RadUpload1.UploadedFiles.Count > 0)  
    { 

And now the UploadedFiles.Count property works as expected.
0
Andy Taslim
Top achievements
Rank 1
answered on 18 Aug 2010, 02:01 PM
Thats a great solution. Will this solution post back the whole page when you hit on upload / submit button?
0
Genady Sergeev
Telerik team
answered on 23 Aug 2010, 10:21 AM
Hi Andy Taslim,

Yes, this precisely what the workaround does. Since full page postback is required for file upload this is the desired behavior.

All the best,
Genady Sergeev
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
Tags
Upload (Obsolete)
Asked by
sircutbreaker
Top achievements
Rank 1
Answers by
sircutbreaker
Top achievements
Rank 1
Genady Sergeev
Telerik team
Bruno
Top achievements
Rank 2
Andy Taslim
Top achievements
Rank 1
Share this question
or