We help IT Professionals succeed at work.

Unable to get ComboBox to display Dropdown List when master page does not exist

pclarke7
pclarke7 asked
on
47 Views
Last Modified: 2020-03-29
I am using an AjaxControlToolkit ComboBox in a C# web application. My Webform page will not display the contents of the dropdown list added in code behind. This works when I have a master page. However I need to remove the m,aster page from the project and this results is the dropdown list not displaying. Appreciate if someone can explain how I can get the dropdown list working without the master page.

regards
Pat

WebForm.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm3.aspx.cs" Inherits="TiosClient.WebForm3" %>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="ajaxToolkit" %>



<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" />
        </div>
        <asp:Button ID="Button2" runat="server" Text="Button" />
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
        
        <ajaxToolkit:ComboBox ID="ComboBox1" runat="server">
        </ajaxToolkit:ComboBox>

         <div >
           <p><ajaxToolkit:ComboBox ID="ComboBox2" runat="server">
            </ajaxToolkit:ComboBox>
            </p>
    </div>


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

</body>
</html> 

Open in new window


WebForm3.aspx.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace TiosClient
{
    public partial class WebForm3 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string test1 = "Testing WenForm3...";
            Button1.Text = test1;
            ComboBox1.ClearSelection();
            ComboBox1.Dispose(); // required to clear previous values
            ComboBox1.Items.Clear();
            ComboBox1.Text = "HelloThere ";
            ComboBox1.Items.Add("Option1");
            ComboBox1.Items.Add("Option2");
            ComboBox1.Items.Add("Option3");
            ComboBox1.Items.Add("Option4");
            ComboBox1.Visible = true;
            ComboBox1.MaxLength = 500;

            ComboBox2.ClearSelection();
            ComboBox2.Dispose(); // required to clear previous values
            ComboBox2.Items.Clear();
            ComboBox2.Text = "HelloThere ";
            ComboBox2.Items.Add("Option1");
            ComboBox2.Items.Add("Option2");
            ComboBox2.Items.Add("Option3");
            ComboBox2.Items.Add("Option4");
            ComboBox2.Visible = true;
            ComboBox2.MaxLength = 500;


        }
    }
}

Open in new window



When I display the content of ComboBox1.ListItem it contains
[0] {Option1}
[1] {Option2}
[2] {Option3}
[3] {Option4}

as expected but when I click on the dropdown arrow there is no content displayed
Comment
Watch Question

Chinmay PatelChief Technology Ninja
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
Hi pclarke7,

It is a hunch as I have not used AJAXToolkit in last 10 years or so, but can you move the ScriptManager to the top of your page please?
Also, can you post your master page's code here? You can remove any sensitve stuff from it before posting it here.

PS: Any specific reason you are using WebForms and AJAXtoolkit?

Regards,
Chinmay.
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.