Avatar of pclarke7
pclarke7

asked on 

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

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
ASPC#* combobox

Avatar of undefined
Last Comment
pclarke7
Avatar of Chinmay Patel
Chinmay Patel
Flag of India image

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.
ASKER CERTIFIED SOLUTION
Avatar of pclarke7
pclarke7

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
C#
C#

C# is an object-oriented programming language created in conjunction with Microsoft’s .NET framework. Compilation is usually done into the Microsoft Intermediate Language (MSIL), which is then JIT-compiled to native code (and cached) during execution in the Common Language Runtime (CLR).

98K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo