troubleshooting Question

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

Avatar of pclarke7
pclarke7 asked on
ASPC#* combobox
2 Comments1 Solution58 ViewsLast Modified:
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> 

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;


        }
    }
}


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
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 2 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros