Solved

Refresh contents of User Control on MasterPage

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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

OverviewThis article demonstrates a simple search form using AJAX. The purpose of the article is to demonstrate how to use the same code to render a page and javascript (JQuery) and AJAX to make subsequent calls to refine the results. The princip…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

895 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

14 Experts available now in Live!

Get 1:1 Help Now