Solved

Refresh contents of User Control on MasterPage

Posted on 2009-05-11
5
1,171 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now