Solved

Refresh contents of User Control on MasterPage

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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