.NET - Render User Control Logo on Postback

I've got a vb.net page that has a company dropdown which causes a postback, and I'm wanting to change the logo at the top of the page with the logo of the selected company. The header bar which has the logo in it is in a user control called Nav.ascx. Due to the order of elements loading on the page, I'm not finding a good way to display the logo in the header unless the user reloads the page or navigates to another page. If I try to reset the logo in the dropdown.SelectedIndesChanged event, that's not working. Any ideas how best to accomplish this?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
is the trigger point from Parent's page or from the User Control?

meaning to say, is the dropdown from the Parent's page or from the User Control?

see if this article is useful for you?

ASP.NET Web Form User Control's Basic Interaction
tablaFreakAuthor Commented:
Thanks, Ryan - Thanks for the article, I'll take a look. And the dropdown list is on the main page, as is the user control for the page header. I can reference the user control inside the Page Init event, where I'm setting the display user name and some user-defined links, but it seems at the page load event it's too late to change what gets rendered in the user control. Not sure what to do other than forcing a second postback, which could trouble the user...
tablaFreakAuthor Commented:
Looks like in the article, data is passed from the user control to the parent page. My case is the other way around - parent page to user control.
Ryan ChongBusiness Systems Analyst , ex-Senior Application EngineerCommented:
let's say in your User Control you got the image control:

<asp:Image ID="Image1" runat="server" />

Open in new window

and you wish it to reflect with a logo image based on the selection of Dropdown list in Parent's Page, then in your Parent's Page (using same sample), you got:

<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True">
            <asp:ListItem Value=""></asp:ListItem>
            <asp:ListItem Value="logo1.png">Logo 1</asp:ListItem>
            <asp:ListItem Value="logo2.png">Logo 2</asp:ListItem>
            <asp:ListItem Value="logo3.png">Logo 3</asp:ListItem>

Open in new window

then in Parent's Page, add this at code behind:

Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs) Handles DropDownList1.SelectedIndexChanged
        Dim image As Image = TryCast(WebUserControl2.FindControl("Image1"), Image)
        Dim label As Label = TryCast(WebUserControl2.FindControl("Label1"), Label)
        If DropDownList1.SelectedValue <> "" Then
            If image IsNot Nothing Then image.ImageUrl = "./images/" + DropDownList1.SelectedValue
            If label IsNot Nothing Then label.Text = "You have selected: " + DropDownList1.SelectedValue
            If image IsNot Nothing Then image.ImageUrl = ""
            If label IsNot Nothing Then label.Text = ""
        End If
    End Sub

Open in new window


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tablaFreakAuthor Commented:
Thanks, that did it!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.