RadUpload in WebUserControl Radgrid

Thread is closed for posting
10 posts, 1 answers
  1. sircutbreaker
    sircutbreaker avatar
    111 posts
    Member since:
    Oct 2007

    Posted 26 Sep 2009 Link to this post

    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



  2. sircutbreaker
    sircutbreaker avatar
    111 posts
    Member since:
    Oct 2007

    Posted 26 Sep 2009 Link to this post

    Nevermind.. the file was too large.. httpruntime fixed it..
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 26 Sep 2009 Link to this post

    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.
  5. sircutbreaker
    sircutbreaker avatar
    111 posts
    Member since:
    Oct 2007

    Posted 26 Sep 2009 Link to this post

    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
  6. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 28 Sep 2009 Link to this post

    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.
  7. Bruno
    Bruno avatar
    16 posts
    Member since:
    May 2008

    Posted 09 Nov 2009 Link to this post

    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.
  8. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 12 Nov 2009 Link to this post

    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.
  9. Bruno
    Bruno avatar
    16 posts
    Member since:
    May 2008

    Posted 20 Nov 2009 Link to this post

    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.
  10. Andy Taslim
    Andy Taslim avatar
    16 posts
    Member since:
    May 2010

    Posted 18 Aug 2010 Link to this post

    Thats a great solution. Will this solution post back the whole page when you hit on upload / submit button?
  11. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 23 Aug 2010 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017