Link to home
Start Free TrialLog in
Avatar of allanmark
allanmark

asked on

Refresh contents of User Control on MasterPage

Greetings all

I have a user control, on an Ajax PopUp control, on a MasterPage, providing an email facility (user clicks an icon and a form is displayed, etc). The user control reads a d/b table and populates a dropdown with names /email addresses (done on PageLoad)

When the user creates a new person, I would like their details to be added to the user control's dropdown list, ie, when the user clicks the "email" icon, and the "Email" form is popped up, the dropdoown will contain the recentl;y added address.

Where do I need to put the loading of the dropdown, in order for this to work?


In advance, thanks!!!

    allanmark
Avatar of tetorvik
tetorvik
Flag of Finland image

if you're creating a new person and loading the dropdown list during a single postback, then you can populate the dropdownlist on user control's page_prerender event. Or alternatively you may create a public method on user control that will update the dropdownlist content. Then you could call this method for example on button click event.

I hope I undesrtood your problem correctly!
Avatar of allanmark
allanmark

ASKER

Like this?

protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);

        emailList = BusinessLogic.Business.GetEmailAddress();
        Session["mailList"] = emailList;
        ddlAddresses.DataSource = emailList;
        ddlAddresses.DataTextField = "Name";
        ddlAddresses.DataValueField = "Email";
        ddlAddresses.DataBind();
        ddlAddresses.SelectedIndex = 0;

        pnlMail.Enabled = ddlAddresses.Items.Count > 0;
       
    }
ASKER CERTIFIED SOLUTION
Avatar of tetorvik
tetorvik
Flag of Finland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
your syntax will do as well...
Many thanks!!