Solved

Refresh contents of User Control on MasterPage

Posted on 2009-05-11
5
1,204 Views
Last Modified: 2013-12-17
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
0
Comment
Question by:allanmark
  • 3
  • 2
5 Comments
 
LVL 9

Expert Comment

by:tetorvik
ID: 24352819
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!
0
 

Author Comment

by:allanmark
ID: 24352980
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;
       
    }
0
 
LVL 9

Accepted Solution

by:
tetorvik earned 250 total points
ID: 24353051
you can use the following as ASP.NET automatically bind events to methods that follows naming conventions Page_EventName
        protected void Page_PreRender(object sender, EventArgs 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;
        }

Open in new window

0
 
LVL 9

Expert Comment

by:tetorvik
ID: 24353128
your syntax will do as well...
0
 

Author Closing Comment

by:allanmark
ID: 31580074
Many thanks!!

0

Featured Post

Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question