telerik template combobox will not open in rad window

5 posts, 0 answers
  1. Jeff Wickersham
    Jeff Wickersham avatar
    24 posts
    Member since:
    Mar 2009

    Posted 18 Jun 2013 Link to this post

    I have a radcombobox control on a pop rad window on a web server that will not open to display the items.
    It does work on my laptop though
    What is the work around?
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 18 Jun 2013 Link to this post

    Hi,
    I was not able to replicate the issue. Here is the sample code and screenshot.
    ASPX:
    <telerik:RadWindowManager ID="RadWindowManager1" runat="server">
     <Windows>
      <telerik:RadWindow ID="NotifyDialog" runat="server" Width="900px" Height="760px">
        <ContentTemplate>
          <telerik:RadComboBox ID="RadComboBox1" runat="server" AllowCustomText="false">
            <Items>
               ...... .... ....
           </Items>
          </telerik:RadComboBox>
        </ContentTemplate>
       </telerik:RadWindow>
     </Windows>
    </telerik:RadWindowManager>
    <asp:Button ID="btnopen" runat="server" Text="open" OnClientClick="return ShowNotificationForm()" />
    JS:
    function ShowNotificationForm() {
         window.radopen(null, "NotifyDialog");
         return false;
      }

    Hope this will help you.
    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Jeff Wickersham
    Jeff Wickersham avatar
    24 posts
    Member since:
    Mar 2009

    Posted 19 Jun 2013 Link to this post

    Shinu,
    Thank you for the input. Perhaps I need to explain the situation better.
    So I have a page that the radWindow is actually opening, in that page there is a templated combobox and an upload control.
    When the user attempts to open the combobox it will not reveal contents.
    Now the funny thing is that it works fine on my dev machine, windows 7 visual stuidio 12, any browser, framework 4.5
    But will not work on production server running iis 7, framework 4.5

    Here is the calling page snippet
       <telerik:RadScriptBlock runat="server">
                <script type="text/javascript">
               
                    function ViewUpload() {
                        var oManager = GetRadWindowManager();
                        oManager.open(null, "ViewUpload");
                    }
                </script>
            </telerik:RadScriptBlock>
            <telerik:RadWindowManager runat="server" ID="DPAWindowManager"
                Title="Dealership Participation Agreement (DPA)"
                VisibleStatusbar="False" Modal="False" Skin="Metro">
                <Windows>
                    <telerik:RadWindow runat="server" ID="ViewUpload" NavigateUrl="Upload.aspx" Width="775px" Height="400px" ShowOnTopWhenMaximized="True" />
                </Windows>
            </telerik:RadWindowManager>

      <form id="form1" runat="server">
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server"/>
            <telerik:RadAjaxPanel runat="server">
            <h2>Dealer Participation Agreement Upload</h2>
            <asp:Label ID="lblMessage" runat="server" /><br />
            <table border="0" cellpadding="0" cellspacing="10">
                <tr>
                    <td valign="top" colspan="3">Dealer<br />
                        <asp:DropDownList ID="ddlDealer" runat="server" Width="700" />
                         <telerik:RadComboBox ID="ddlDealer"
                            ZIndex=""
                            runat="server"
                            AutoCompleteSeparator=""
                            CausesValidation="False"
                            Height="200px" MarkFirstMatch="True"
                            EnableLoadOnDemand="true"
                            HighlightTemplatedItems="True"
                            OnClientItemsRequested="UpdateItemCountField"
                            OnDataBound="ddlDealer_DataBound"
                            OnItemDataBound="ddlDealer_ItemDataBound"
                            OnItemsRequested="ddlDealer_ItemsRequested"
                            Skin="Metro" Width="700px">
                            <HeaderTemplate>
                                <ul>
                                    <li class="col1">Dealer</li>
                                    <li class="col2">FDAF</li>
                                    <li class="col3">DealerId</li>
                                </ul>
                            </HeaderTemplate>
                            <ItemTemplate>
                                <ul>
                                    <li class="col1">
                                        <%# DataBinder.Eval(Container.DataItem, "Dealer") %></li>
                                    <li class="col2">
                                        <%# DataBinder.Eval(Container.DataItem, "RegionName") %></li>
                                    <li class="col3">
                                        <%# DataBinder.Eval(Container.DataItem, "DealerId") %></li>
                                </ul>
                            </ItemTemplate>
                            <FooterTemplate>
                                Dealer Count:
                        <asp:Literal runat="server" ID="DealerCount" />

                            </FooterTemplate>
                        </telerik:RadComboBox>
                    </td>
                </tr>
              
                <tr>
                    <td valign="top">
                        <telerik:RadUpload ID="RadUpload1" runat="server" InitialFileInputsCount="1" MaxFileInputsCount="1" Skin="Metro"
                            AllowedFileExtensions=".pdf" />
                        <telerik:RadProgressArea runat="server" ID="RadProgressArea1" OnClientProgressUpdating="checkUploadedFilesSize" />
                        <telerik:RadProgressManager runat="server" ID="RadProgressManager1" /><br />
                         
                        <telerik:RadButton ID="btnSave" runat="server" CausesValidation="true" OnClick="btnSave_Click" Skin="Metro" Text="Save" Width="75px">
                             <Icon SecondaryIconUrl="images/save.png" SecondaryIconLeft="5" SecondaryIconTop="3"/>
                        </telerik:RadButton>
                    </td>
                    <td valign="top">
                        <asp:Label ID="lblUpload" runat="server"></asp:Label>
                        <asp:Repeater ID="repeaterValidResults" runat="server" Visible="False">
                            <ItemTemplate>
                                <%#DataBinder.Eval(Container.DataItem, "FileName")%>
                                (<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>)<br />
                                <br />
                            </ItemTemplate>
                        </asp:Repeater>
                        <asp:Label ID="lblNoUpload" runat="server"></asp:Label>
                        <asp:Repeater ID="repeaterInvalidResults" runat="server" Visible="False">
                            <ItemTemplate>File:
                                <%#DataBinder.Eval(Container.DataItem, "FileName") %>
                                (<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>)
                                <br />
                                Mime-type:
                                <%#DataBinder.Eval(Container.DataItem, "ContentType").ToString()%>
                            </ItemTemplate>
                        </asp:Repeater>
                    </td>
                </tr>
            </table>
            <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                <script type="text/javascript">
                    function UpdateItemCountField(sender, args) {
                        //Set the footer text.
                        sender.get_dropDownElement().lastChild.innerHTML = "Dealer Count: " + sender.get_items().get_count();
                    }
                </script>
            </telerik:RadScriptBlock>
          <script type="text/javascript">
                function checkUploadedFilesSize(progressArea, args) {
                    //progressArea.confirmed is a custom variable,
                    // you can use another if you want to
                    if (!progressArea.confirmed &&
           args.get_progressData().RadUpload.RequestSize > 1000000) {
                        if (confirm("The total size of the selected files" +
                     " is more than the limit." +
                     " Do you want to cancel the upload?")) {
                            progressArea.cancelRequest();
                        }
                        else {
                            progressArea.confirmed = "confirmed";
                        }
                    }
                }
            </script>

     </telerik:RadAjaxPanel>
        </form>


    public partial class FordDirect_Upload : System.Web.UI.Page
    {
        FileUpload objFileUpload = new FileUpload();

        protected void Page_Load(object sender, EventArgs e)
        {
            objFileUpload.UserName = System.Web.HttpContext.Current.User.Identity.Name;
            if (!Page.IsPostBack)
            {
                DeleteFiles();
                LoadDealers();
            }
        }
       private void LoadDealers()
       {
           String query = "SELECT d.lDealerID AS DealerId " +
                          " ,UPPER(d.szDealer) +' ' +RegionCode +' ' + RegionName As Dealer" +
                          " ,UPPER(fr.szFDAFRegionCode) RegionCode " +
                          " ,UPPER(fr.szFDAFRegionCode) RegionName " +
                          " FROM tblDealer AS d " +
                          " INNER JOIN tblFDAFDealerRegionMap AS rm ON rm.lDealerId = d.lDealerID " +
                          " INNER JOIN  dbo.tblFDAFRegions fr ON rm.lFDAFRegionCodeId = fr.lFDAFRegionCodeId " +
                           "ORDER BY Dealer";
           DataTable dt = LoadDataTable(query);
           ddlDealer.DataSource = dt;
           ddlDealer.DataBind();
       }

        protected void ddlDealer_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e)
        {
            String query = "SELECT d.lDealerID AS DealerId " +
                           " ,UPPER(d.szDealer) AS Dealer " +
                           " ,UPPER(fr.szFDAFRegionCode) RegionCode " +
                           " ,UPPER(fr.szFDAFRegionCode) RegionName " +
                           " FROM tblDealer AS d " +
                           " INNER JOIN tblFDAFDealerRegionMap AS rm ON rm.lDealerId = d.lDealerID " +
                           " INNER JOIN  dbo.tblFDAFRegions fr ON rm.lFDAFRegionCodeId = fr.lFDAFRegionCodeId " +
                            "ORDER BY Dealer";
            DataTable dt = LoadDataTable(query);
            ddlDealer.DataSource = dt;
            ddlDealer.DataBind();
        }

        protected void ddlDealer_ItemDataBound(object sender, RadComboBoxItemEventArgs e)
        {
            e.Item.Text = ((DataRowView)e.Item.DataItem)["Dealer"].ToString();
            e.Item.Value = ((DataRowView)e.Item.DataItem)["DealerId"].ToString();
        }

        protected void ddlDealer_DataBound(object sender, EventArgs e)
        {
            //((Literal)ddlDealer.Footer.FindControl("DealerCount")).Text = Convert.ToString(ddlDealer.Items.Count);
        }


        public DataTable LoadDataTable(string query)
        {
            using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["DSS"].ToString()))
            {
                SqlDataAdapter dap = new SqlDataAdapter(query, connection);
                DataTable dt = new DataTable();
                dap.Fill(dt);
                return dt;
            }
        }
        protected void btnSave_Click(object sender, System.EventArgs e)
        {
            BindValidResults();
            BindInvalidResults();
        }

        private void BindValidResults()
        {
            if (RadUpload1.UploadedFiles.Count > 0)
            {
                foreach (UploadedFile mediaFile in RadUpload1.UploadedFiles)
                {
                    String fileName = Path.GetFileName(mediaFile.FileName);
                    objFileUpload.UploadFolder = Server.MapPath("~/Media/Files");
                    objFileUpload.FilePath = objFileUpload.UploadFolder + @"\" + fileName;
                    mediaFile.SaveAs(Path.Combine(objFileUpload.UploadFolder, fileName), true);
                    byte[] bytes = File.ReadAllBytes(objFileUpload.FilePath);
                    objFileUpload.OwnerId = ddlDealer.SelectedValue;
                    objFileUpload.Expiration = DateTime.Now.AddYears(10);


                    using (SqlConnection sqlConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["DSS"].ConnectionString))
                    {
                        try
                        {
                            lblMessage.Text = "";
                            const string SQL = "INSERT INTO [tblFDAFMedia] ([szMediaTitle], [iMediaData], [szMediaName], [szMediaType], [szOwnerId], [dtCreatedOn], [szCreatedBy], [dtExpiration]) "
                                                + "VALUES (@MediaTitle, @MediaData, @MediaName, @MediaType,  @OwnerId, @CreatedOn, @CreatedBy, @Expiration)";
                            SqlCommand sqlCommand = new SqlCommand(SQL, sqlConnection);
                            sqlCommand.Parameters.AddWithValue("@MediaTitle", objFileUpload.MediaTitle);
                            sqlCommand.Parameters.AddWithValue("@MediaData", bytes);
                            sqlCommand.Parameters.AddWithValue("@MediaName", mediaFile.FileName);
                            sqlCommand.Parameters.AddWithValue("@MediaType", "DPA");
                            sqlCommand.Parameters.AddWithValue("@OwnerId", objFileUpload.OwnerId);
                            sqlCommand.Parameters.AddWithValue("@CreatedOn", DateTime.Now);
                            sqlCommand.Parameters.AddWithValue("@CreatedBy", objFileUpload.UserName);
                            sqlCommand.Parameters.AddWithValue("@Expiration", objFileUpload.Expiration);

                            sqlConnection.Open();
                            sqlCommand.ExecuteNonQuery();

                            lblMessage.Text = "<h2>Upload Successful!</h2>";
                        }
                        catch (Exception ex)
                        {
                            lblMessage.Text = ex.Message;
                            
                        }
                        finally
                        {
                            if (sqlConnection.State == System.Data.ConnectionState.Open)
                            {
                                sqlConnection.Close();
                            }
                        }
                    }
                }

                lblNoUpload.Visible = false;
                repeaterValidResults.Visible = true;
                repeaterValidResults.DataSource = RadUpload1.UploadedFiles;
                repeaterValidResults.DataBind();
            }
            else
            {
                //lblNoUpload.Text = "<h2>No Files Uploaded!</h2>";
                lblNoUpload.Visible = true;
                repeaterValidResults.Visible = false;
                return;
            }
        }

        private void BindInvalidResults()
        {
            if (RadUpload1.InvalidFiles.Count > 0)
            {
                lblNoUpload.Visible = false;
                repeaterInvalidResults.Visible = true;
                lblMessage.Text = "<h2>Invalid file type only .PDF is allowed</h2>";
                repeaterInvalidResults.DataSource = RadUpload1.InvalidFiles;
                repeaterInvalidResults.DataBind();
            }
            else
            {
                lblNoUpload.Text = "<h2>No Files Uploaded!</h2>";
                lblUpload.Visible = true;
                repeaterInvalidResults.Visible = false;
            }
        }

        private void DeleteFiles()
        {
            string targetFolder = Server.MapPath("~/Media/Files");

            DirectoryInfo targetDir = new DirectoryInfo(targetFolder);

            try
            {
                foreach (FileInfo file in targetDir.GetFiles())
                {
                    file.Delete();
                }
            }
            catch (IOException)
            {
            }
        }
    }


  5. Jeff Wickersham
    Jeff Wickersham avatar
    24 posts
    Member since:
    Mar 2009

    Posted 19 Jun 2013 Link to this post

    So when running the page using fiddler I get this 500 error
    http://ccworks2/Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScripts_=%3b%3bAjaxControlToolkit%2c+Version%3d4.1.40412.0%2c+Culture%3dneutral%2c+PublicKeyToken%3d28f01b0e84b6d53e%3aen-US%3aacfc7575-cdee-46af-964f-5d85d9cdcf92%3aea597d4b%3ab25378d2%3bTelerik.Web.UI%2c+Version%3d2013.2.611.45%2c+Culture%3dneutral%2c+PublicKeyToken%3d121fae78165ba3d4%3aen-US%3a9711a23a-6cf5-4e6c-87f5-29e6585b3026%3a16e4e7cd%3af7645509%3a2003d0b8%3a24ee1bba%3af46195d3%3a1e771326%3aaa288e2d%3aa585d0d4%3a874f8ea2%3a2a2fc429%3a68f76a79%3a7165f74

    what is all this indicate?
  6. Marin Bratanov
    Admin
    Marin Bratanov avatar
    3595 posts

    Posted 21 Jun 2013 Link to this post

    Hello Jeff,

    Once I ran the page from the attached snippets things seem to work fine with me (without the dependencies I cannot emulate, of course). Could you compare what you have with what I have attached and try to find the difference that is causing the problem?

    On the error you get I can suggest the following:
    - see if using the scripts CDN we offer helps
    - make sure you are using the latest version (Q2 2013 at present)
    - try disabling the script combination from the RadScriptManager to see which is the exact resource that fails (EnableScriptCombine=false).
    - use this blog post to find the offending resource name and see if replacing it with an external reference as shown here helps
    - go through this help article on troubleshooting server errors with webresources (especially the last part) and this one on general troubleshooting.

    And, to answer the last question - this indicates to me, that there is an issue with loading a script in the content page in the RadWindow and not in the RadWindow control. I hope the above ideas will help you resolve it. Having a broken script is likely to cause JS errors that can break our controls and the combobox does not open because of this, I think.


    Regards,
    Marin Bratanov
    Telerik
    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 the blog feed now.
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017