Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7699491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:29:27+00:00 2026-05-31T22:29:27+00:00

I have a user control which is 2 RadCombos cascaded. I’m trying to add

  • 0

I have a user control which is 2 RadCombos cascaded. I’m trying to add these to my page at runtime. The problem is the Page_Load JS function of the user control never fires. Also whenever the Page_Load of the aspx.cs fires IsPostback is always true. Can anyone help?

Control code behind:

public partial class ctrlCascadedProcedureDropDown : System.Web.UI.UserControl
{
    public int ProcedureTypeSelectedValue { get; set; }
    public int ProcedureSelectedValue { get; set; }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadProcedureTypes();

            if (ProcedureTypeSelectedValue > 0)
                LoadProcedures(ProcedureTypeSelectedValue.ToString());

            rcbProcedureType.SelectedValue = ProcedureTypeSelectedValue.ToString();
            rcbProcedure.SelectedValue = ProcedureSelectedValue.ToString();
        }
        else if (!Page.IsCallback)
        {
            if (rcbProcedureType != null)
                LoadProcedures(rcbProcedureType.SelectedValue);
        }
    }

    protected void rcbProcedureType_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
    {
        LoadProcedureTypes();
    }

    protected void rcbProcedure_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e)
    {
        LoadProcedures(e.Text);
    }

    protected void LoadProcedureTypes()
    {
        TARNDB.OpsProcedureType opsProcedureType = new TARNDB.OpsProcedureType();
        rcbProcedureType.DataSource = opsProcedureType.GetProcedureTypes().OrderBy(x => x.ProcedureType);;
        rcbProcedureType.DataValueField = "ID";
        rcbProcedureType.DataTextField = "ProcedureType";
        rcbProcedureType.DataBind();

        rcbProcedureType.Items.Insert(0, new RadComboBoxItem(""));  
    }

    protected void LoadProcedures(string proceduretypeid)
    {
        int _proceduretypeid;
        if (int.TryParse(proceduretypeid, out _proceduretypeid))
        {
            TARNDB.OpsProcedure opsProcedure = new TARNDB.OpsProcedure();
            rcbProcedure.DataSource = opsProcedure.GetProcedures(_proceduretypeid).OrderBy(x => x.ProcedureName); ;
            rcbProcedure.DataValueField = "ID";
            rcbProcedure.DataTextField = "ProcedureName";
            rcbProcedure.DataBind();
        }
    }
}

Control mark-up:

<div>
<telerik:RadComboBox ID="rcbProcedureType" runat="server" 
    OnClientSelectedIndexChanging="LoadProcedures" 
    OnItemsRequested="rcbProcedureType_ItemsRequested" />
<telerik:RadComboBox ID="rcbProcedure" runat="server" Width="250px" 
    OnClientItemsRequested="ItemsLoaded"
    OnItemsRequested="rcbProcedure_ItemsRequested" />
</div>

<script type="text/javascript">

var rcbProcedure;
var rcbProcedureType;

function pageLoad() {
    rcbProcedure = $find("<%= rcbProcedure.ClientID %>");
    rcbProcedureType = $find("<%= rcbProcedureType.ClientID %>");

    alert("in");
}

function LoadProcedures(sender, eventArgs) {
    var item = eventArgs.get_item();
    rcbProcedure.set_text("Loading...");

    // if a procedure type is selected
    if (item.get_index() > 0) {
        // this will fire the ItemsRequested event of the 
        // procedures combobox passing the procedureTypeID as a parameter 
        rcbProcedure.requestItems(item.get_value(), false);
    }
    else {
        // the -Select a continent- item was chosen
        rcbProcedure.set_text(" ");
        rcbProcedure.clearItems();
    }
}

function ItemsLoaded(sender, eventArgs) {
    if (sender.get_items().get_count() > 0) {            
        // pre-select the first item
        sender.set_text(sender.get_items().getItem(0).get_text());
        sender.get_items().getItem(0).highlight();
    }
    //sender.showDropDown();
}

</script>

Calling code:

public partial class Operations : BasePage
{
    public List<DynamicControl> DynamicControls
    {
        get
        {
            return (List<DynamicControl>)Session["_DynamicControls"];
        }
        set
        {
            Session["_DynamicControls"] = value;
        }
    }

    protected void Page_Init(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            DynamicControls = null;
        }
        else
        {
            if (DynamicControls != null && DynamicControls.Count > 0)
            {
                foreach (DynamicControl control in DynamicControls)
                {
                    ctrlCascadedProcedureDropDown cpd = new ctrlCascadedProcedureDropDown();
                    cpd.ID = control.ID;

                    switch (control.PlaceHolder.ID)
                    {
                        case "phProcedure":
                            phProcedure.Controls.Add(cpd);
                            phProcedure.Controls.Add(new Literal() { Text = "<BR />" });
                            break;
                        default:
                            break;
                    }
                }
            }
        }
    }

    protected void btnAddProcedure_Click(object sender, EventArgs e)
    {
        AddDynamicProcedureControl("Procedure", phProcedure);
    }

    private void AddDynamicProcedureControl(string name, PlaceHolder placeHolder, int procedureTypeSelectedValue = 0, 
        int procedureSelectedValue = 0)
    {
        Control control = LoadControl("~/Controls/ctrlCascadedProcedureDropDown.ascx");
        ctrlCascadedProcedureDropDown cpd = (ctrlCascadedProcedureDropDown)control;

        int controlCount = (DynamicControls == null ? 0 : DynamicControls.Count);
        string ID = string.Concat(name, controlCount.ToString());
        cpd.ID = ID;
        cpd.ProcedureTypeSelectedValue = procedureTypeSelectedValue;
        cpd.ProcedureSelectedValue = procedureSelectedValue;

        DynamicControl dc = new DynamicControl() { ID = ID, PlaceHolder = placeHolder };
        if (DynamicControls == null)
            DynamicControls = new List<DynamicControl>();
        DynamicControls.Add(dc);

        placeHolder.Controls.Add(cpd);
        placeHolder.Controls.Add(new Literal() { Text = "<BR />" });
    }

    private List<int> GetDynamicList(PlaceHolder placeHolder)
    {
        List<int> list = null;
        list = new List<int>();
        foreach (Control control in placeHolder.Controls)
        {
            if (control is GenericDropDown)
            {
                int id;
                if (int.TryParse(((GenericDropDown)control).SelectedValue, out id) && id > 0)
                    list.Add(id);
            }
        }

        return list;
    }
}

Many thanks,
Paul

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:29:28+00:00Added an answer on May 31, 2026 at 10:29 pm

    I wasn’t using LoadControl in the PageInIt.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a user control which I would like to add a dependency property
I have a User Control which renders a simple drop downList into the page.
I have a user control which is being loaded to the page dynamically after
I have a user control which takes a Func which it then gives to
I have a user control which has a textbox on it, now this usercontrol
I have a user control which does some validation in the ValidateChildren method which
I have a user control which displays the currently logged in user's name. I
I have a user control which uses objects as inner properties (some code is
I have a user control which has a DateTimePicker overlaid with the single line
I have user control named DateTimeUC which has two textboxes on its markup: <asp:TextBox

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.