Repeater with Web user control

Thread is closed for posting
6 posts, 0 answers
  1. Quan Nguyen
    Quan Nguyen avatar
    8 posts
    Member since:
    Aug 2009

    Posted 09 Feb 2011 Link to this post

    Hello,

    I'm have a similar setup to this demo: http://demos.telerik.com/aspnet-ajax/tooltip/examples/default/defaultcs.aspx.
    Where I have a repeater, radtooltipmanager that loads a Web User Control that contains a RadUpload and a submit button.
    The key difference between the demo and my is that I have a RadUpload control on the Web User Control.
    I can't get the RadUpload to work. I understand that I have to disable AJAX somehow,
    but can't seem to get to work properly.

    Please advise.

    Thanks,
    Quan

     
  2. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 14 Feb 2011 Link to this post

    Hi Quan,

    You can't use RadUpload and ajax requests due to a limitation of the XMLHttpRequest object, so when you want to upload files from ajaxified container you should disable the AJAX and make a full page post-back.

    So in your case you should fetch the AJAX request from the submit button, cancel it and perform full page post-back. More information how to do it you could find here.

    I hope this would solve your issue.

    Kind regards,
    Dimitar Terziev
    the Telerik team
    Browse the vast support resources we have to jump start 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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Quan Nguyen
    Quan Nguyen avatar
    8 posts
    Member since:
    Aug 2009

    Posted 15 Feb 2011 Link to this post

    Hello Dimitar,

    Thanks for responding!
    I'm not having much luck. Please see the code below.

    Thanks again,
    Quan

          //Default.aspx.cs
      
           protected void rptEmployees_ItemDataBound(object sender, RepeaterItemEventArgs e)
            {
                Control TargetControl = e.Item.FindControl("hplID");
     
                DataRowView currentRow = (DataRowView)e.Item.DataItem;
                string key = currentRow.Row["Employee_ID"].ToString();
     
                RadToolTipManager1.TargetControls.Add(TargetControl.ClientID, currentRow.Row["Employee_ID"].ToString(), true);
     
                UserControl userControl = (UserControl)e.Item.FindControl(RadToolTipManager1.ClientID);
     
                RadUpload upload = userControl.FindControl("RadButtonUpload") as RadUpload;
     
                RadAjaxPanel1.ResponseScripts.Add(string.Format("window['UploadId'] = '{0}';", upload.ClientID));
            }
     
          //Default.aspx
     
                    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" ClientEvents-OnRequestStart="conditionalPostback">
                             
                    <asp:Repeater ID="rptEmployees" runat="server" OnItemDataBound="rptEmployees_ItemDataBound">
                        <ItemTemplate>
                        <tr class='<%# Container.ItemIndex % 2 == 0 ? "upper" : "Lower"  %>'>
                              
                           <td width="3%" valign="top" style="text-align:left; border-collapse:collapse; border-right: hidden; border-bottom: hidden; border-bottom:hidden; border-top:hidden;">
                               <asp:CheckBox ID="CheckBox1" runat="server" />
                           </td>
     
                            <td width="3%" valign="top" style="text-align:left; border-collapse:collapse; border-right: hidden; border-bottom: hidden; border-bottom:hidden; border-top:hidden;">
                                <asp:HyperLink ID="hplID" runat="server" NavigateUrl="#" style="text-decoration:none" Text='<%# DataBinder.Eval(Container.DataItem, "[Employee_ID]").ToString() %>'></asp:HyperLink>
                            </td>
                            <td width="5%" valign="top" style="text-align:left; border-collapse:collapse; border-right: hidden; border-bottom: hidden; border-bottom:hidden; border-top:hidden;">
                                <asp:HyperLink ID="hplLastName" runat="server"   ToolTip="Click to navigate to Employee page."  style="text-decoration:none"><%# DataBinder.Eval(Container.DataItem, "[Employee_Last_Name]").ToString() %></asp:HyperLink>
                            </td>
                            <td width="5%" valign="top" style="text-align:left">
                                <%# DataBinder.Eval(Container.DataItem, "[Employee_Middle_Name]")%></td>
                            <td width="5%" valign="top" style="text-align:left">
                                <%# DataBinder.Eval(Container.DataItem, "[Employee_First_Name]")%></td>
                            <td width="10%" valign="top">
                                <%# DataBinder.Eval(Container.DataItem, "[Company_Name]")%></td>
                            <td width="5%" valign="top">
                                <%# DataBinder.Eval(Container.DataItem, "[Employee_BG_Check_Type]")%></td>
                            <td width="5%" valign="top">
                                <asp:HyperLink ID="hplNDA" runat="server" enabled='<%# CheckFileExists(DataBinder.Eval(Container.DataItem, "[Employee_NDA_File]").ToString(), DataBinder.Eval(Container.DataItem, "[Employee_NDA]").ToString()) %>' NavigateUrl='<%# String.Format("~/GenerateFile.aspx?File={0}", DataBinder.Eval(Container.DataItem, "[Employee_NDA_File]").ToString()) %>'  ToolTip='<%# DataBinder.Eval(Container.DataItem, "[Employee_NDA]").ToString().ToLower() == "yes" ?  "Click to open Non-Disclosure Agreement document in PDF format." : "" %>'  style="text-decoration:none"><%# DataBinder.Eval(Container.DataItem, "[Employee_NDA]").ToString().ToLower() == "yes" ? "Y" : "N"%></asp:HyperLink>
                            </td>
                            <td width="5%" valign="top">
                                <asp:HyperLink ID="hplAuthorization" runat="server" enabled='<%# CheckFileExists(DataBinder.Eval(Container.DataItem, "[Employee_Authorization_File]").ToString(), DataBinder.Eval(Container.DataItem, "[Employee_Authorization]").ToString()) %>' NavigateUrl='<%# String.Format("~/GenerateFile.aspx?File={0}", DataBinder.Eval(Container.DataItem, "[Employee_Authorization_File]").ToString()) %>' ToolTip='<%# DataBinder.Eval(Container.DataItem, "[Employee_Authorization]").ToString().ToLower() == "yes" ?  "Click to open Authorization document in PDF format." : "" %>' style="text-decoration:none"><%# DataBinder.Eval(Container.DataItem, "[Employee_Authorization]").ToString().ToLower() == "yes" ? "Y" : "N"%></asp:HyperLink>
                            </td>
                            <td width="5%" valign="top">
                                <asp:HyperLink ID="hplICA" runat="server"  enabled='<%# CheckFileExists(DataBinder.Eval(Container.DataItem, "[Employee_ICA_File]").ToString(), DataBinder.Eval(Container.DataItem, "[Employee_ICA]").ToString()) %>' NavigateUrl='<%# String.Format("~/GenerateFile.aspx?File={0}", DataBinder.Eval(Container.DataItem, "[Employee_ICA_File]").ToString()) %>' ToolTip='<%# DataBinder.Eval(Container.DataItem, "[Employee_ICA]").ToString().ToLower() == "yes" ?  "Click to open Individual Contractor Acknowledgement document in PDF format." : "" %>' style="text-decoration:none"><%# DataBinder.Eval(Container.DataItem, "[Employee_ICA]").ToString().ToLower() == "yes" ? "Y" : "N"%></asp:HyperLink>
                            </td>
                            <td width="5%" valign="top" class='<%# DataBinder.Eval(Container.DataItem, "[Employee_Access_Denied]").ToString().ToLower() == "yes" ?  "yes" : "no" %>'>
                                <%# DataBinder.Eval(Container.DataItem, "[Employee_Access_Denied]").ToString().ToLower() == "yes" ? "Y" : "N"%></td>
     
                        </tr>
                        </ItemTemplate>
                    </asp:Repeater>
                     
                    </telerik:RadAjaxPanel>
     
     
     //EmployeeDetails.ascx
     
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EmployeeDetails.ascx.cs" Inherits="EmployeeDetails" %>
     
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
     
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
     
    <link href="StyleSheet.css" rel="stylesheet" type="text/css" />
     
     <table style="width: 100%;">
        <tr>
            <td>
        <div style="width: 750px;" align="center">
          <fieldset id="Fieldset1">
           <legend>Employee Information</legend>
            <table style="width: 100%;">
                <tr>
                    <td align="right" width="100px">
                        First:
                    </td>
                    <td align="left" width="200px">
                       <telerik:RadTextBox ID="RadTextBoxFirst" runat="server" EmptyMessage="" Skin="WebBlue" Width="155px">
                       </telerik:RadTextBox>
     
                    </td>
                     
                    <td align="right" width="100px">
                        Company:
                    </td>
                    <td align="left" width="350px">
                                <telerik:RadComboBox ID="RadComboBoxCompany" runat="server"
                                    ZIndex="9000"
                                    EmptyMessage="Choose a company"
                                    EnableLoadOnDemand="false" 
                                    HighlightTemplatedItems="True"
                                    AutoPostBack="false"
                                    BorderStyle="None"
                                    Skin="WebBlue"
                                    AllowCustomText="False">
                                </telerik:RadComboBox>
     
                    </td>               
                </tr>
                <tr>
                    <td align="right">
                        Middle:
                    </td>
                    <td align="left">
                       <telerik:RadTextBox ID="RadTextBoxMiddle" runat="server"  EmptyMessage="" Skin="WebBlue" Width="155px">
                       </telerik:RadTextBox>
                    </td>
                     
                    <td align="right">
                        DL#:
                    </td>
                    <td align="left">
                       <telerik:RadTextBox ID="RadTextBoxDL" runat="server" EmptyMessage="" Skin="WebBlue" Width="155px">
                       </telerik:RadTextBox>
                    </td>
                                     
                </tr>
                <tr>
                    <td align="right">
                        Last:
                    </td>
                    <td align="left">
                       <telerik:RadTextBox ID="RadTextBoxLast" runat="server"  EmptyMessage="" Skin="WebBlue" Width="155px">
                       </telerik:RadTextBox>
                    </td>
                     
                    <td align="right">
                        DOB:
                    </td>
                    <td align="left">
                       <telerik:RadTextBox ID="RadTextBoxDOB" runat="server" EmptyMessage="" Skin="WebBlue" Width="155px">
                       </telerik:RadTextBox>
                    </td>
                                     
                </tr>
            </table>
            </fieldset>
         </div>
            </td>
        </tr>
        <tr>
            <td>
      <div style="width: 750px;">
          <fieldset id="Fieldset2">
           <legend>Employee Background</legend>
            <table style="width: 100%;">
                <tr>
                    <td align="right" width="100px">
                        Check Type:
                    </td>
                    <td width="200px">
                                <telerik:RadComboBox ID="RadComboBoxType" runat="server"
                                    ZIndex="9000"
                                    EmptyMessage="Choose a type"
                                    EnableLoadOnDemand="false" 
                                    HighlightTemplatedItems="True"
                                    AutoPostBack="false"
                                    BorderStyle="None"
                                    Skin="WebBlue"
                                    AllowCustomText="False">
                                </telerik:RadComboBox>
     
                    </td>
                     
                    <td align="right" width="100px">
                        NDA:
                    </td>
                    <td width="40px">
                                  <asp:CheckBox
                                    ID="CheckBoxNDA"
                                    runat="server"
                                    ToolTip="Yes, if checked."
                                    />
                   
                    </td>
                    <td width="300px">
                                     
                                     
                                <telerik:RadUpload
                                    ID="RadUploadNDA"
                                    runat="server"
                                    InitialFileInputsCount="1"
                                    ControlObjectsVisibility="None"
                                    Skin="WebBlue"
                                    AllowedFileExtensions=".pdf"
                                    Width="40px"
                                    TargetPhysicalFolder="C:\DFI\Software Development\Contractor\Contractor"
                                    AutoPostBack="true"/>
     
                    </td>
                </tr>
     
                <tr>
                    <td align="right">
                        Check Date:
                    </td>
                    <td>
                       <telerik:RadTextBox ID="RadTextBoxCheckDate" runat="server" EmptyMessage="" Skin="WebBlue" Width="155px">
                       </telerik:RadTextBox>
     
                    </td>
                     
                    <td align="right">
                        Authorization:
                    </td>
                    <td>
                                <asp:CheckBox
                                    ID="CheckBoxAuthorization"
                                    runat="server"
                                    ToolTip="Yes, if checked."
                                    />               
                    </td>
                    <td>
                                <telerik:RadUpload
                                    ID="RadUploadAuthorization"
                                    runat="server"
                                    InitialFileInputsCount="1"
                                    ControlObjectsVisibility="None"
                                    Skin="WebBlue"
                                    AllowedFileExtensions=".pdf" Width="40px"/>
                    </td>
                                     
                </tr>
     
                <tr>
                    <td align="right">
                        Check By:
                    </td>
                    <td>
                       <telerik:RadTextBox ID="RadTextBoxCheckBy" runat="server"  EmptyMessage="" Skin="WebBlue" Width="155px">
                       </telerik:RadTextBox>
     
                    </td>
                     
                    <td align="right">
                        ICA:
                    </td>
                    <td>
                                <asp:CheckBox
                                    ID="CheckBoxICA"
                                    runat="server"
                                    ToolTip="Yes, if checked."
                                    />
                     
                    </td>
                    <td>
                                     
                                <telerik:RadUpload
                                    ID="RadUploadICA"
                                    runat="server"
                                    InitialFileInputsCount="1"
                                    ControlObjectsVisibility="None"
                                    Skin="WebBlue"
                                    AllowedFileExtensions=".pdf" Width="40px"/>
                    </td>               
                </tr>
                <tr>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td>
                            <telerik:RadButton
                                ID="RadButtonUpload"
                                runat="server"
                                Text="Upload"
                                Skin="WebBlue"
                                onclick="RadButtonUpload_Click"/>
             
                </td>
                </tr>
     
            </table>
            </fieldset>
         </div>
            </td>
        </tr>
        <tr>
            <td>
      <div style="width: 750px;">
          <fieldset id="Fieldset3">
           <legend>Emmployee Access</legend>
            <table style="width: 100%;" align="center">
                <tr>
                    <td align="right" width="100px">
                        Access Denied:
                    </td>
                    <td width="200px">
                                <asp:CheckBox
                                    ID="CheckBoxDenied"
                                    runat="server"
                                    ToolTip="Yes, if checked."
                                    />
                    </td>
                     
                    <td align="right" width="100px">
                        Notes:
                    </td>
                    <td width="350px">
                       <telerik:RadTextBox ID="RadTextBoxNotes" runat="server"  EmptyMessage="" Skin="WebBlue" Width="200px">
                       </telerik:RadTextBox>
                    </td>
                     
                </tr>
                 
                <tr>
                    <td align="right">
                        Date Denied:
                    </td>
                    <td>
                       <telerik:RadTextBox ID="RadTextBoxDate" runat="server"  EmptyMessage="" Skin="WebBlue" Width="155px">
                       </telerik:RadTextBox>
     
                    </td>
                    <td></td>
                    <td></td>
                     
                </tr>
     
                 
                <tr>
                    <td align="right">
                        Archived:
                    </td>
                    <td>
                                <asp:CheckBox
                                    ID="CheckBoxArchived"
                                    runat="server"
                                    ToolTip="Yes, if checked."
                                    />               
                    </td>
                     
                    <td></td>
                    <td>
                        <telerik:RadButton ID="Button1" runat="server" Text="Submit" Skin="WebBlue"/>
     
                    </td>
                     
                </tr>
                </table>
            </fieldset>
         </div>
            </td>
        </tr>
    </table>
     
    </telerik:RadAjaxPanel>
  5. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1596 posts

    Posted 18 Feb 2011 Link to this post

    Hi Quan Nguyen,

    I can't find the conditionalPostback function declared on your page. Please use this function, it will disable AJAX on file upload:

    function conditionalPostback(sender, args)
     {
         if (args.get_eventTarget().indexOf("RadButtonUpload") > 0)
         {
        
              var upload = $find('<%= RadUpload1.ClientID %>');
              args.set_enableAjax(false);
         }
     }


    Kind regards,
    Genady Sergeev
    the Telerik team
  6. Quan Nguyen
    Quan Nguyen avatar
    8 posts
    Member since:
    Aug 2009

    Posted 18 Feb 2011 Link to this post

    Hello Genady,

    Thanks! I forgot to copy this code snippet below.
    In therptEmployees_ItemDataBound method the usercontrol always return null.


    function conditionalPostback(sender, args) {
         var theRegexp = new RegExp("\.RadButtonUpload$", "ig");
         alert("test");
          
         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);
             }
         }
     }

  7. Dimitar Terziev
    Admin
    Dimitar Terziev avatar
    1266 posts

    Posted 25 Feb 2011 Link to this post

    Hi Quan,

    The reason that your UserControl is always returning null , is that you are not loading it properly. Instead of your implementation :

    UserControl userControl = (UserControl)e.Item.FindControl(RadToolTipManager1.ClientID);

     which is trying to find our RadToolTipManager1 and cast it to UserControl, try the following:

    UserControl UserControl = (UserControl)Page.LoadControl("EmployeeDetails.ascx");

     The second problem which I'm seeing is, that you are trying to locate RadButtonUpload control , which is a RadButton and cast it to RadUpload control:

    RadUpload upload = userControl.FindControl("RadButtonUpload") as RadUpload;

    Please try to fix these problems and if you continue to experience your problem , open a support ticket and send us a runnable version of your project in order to debug it and find the cause of your issue.

    All the best,
    Dimitar Terziev
    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017