Solved

Refresh contents of User Control on MasterPage

Posted on 2009-05-11
5
1,213 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

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.
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

634 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