locked
Update Panel On Master Page RRS feed

  • Question

  • User-962670764 posted

    I have an Image control a Master Page that the user can change from a content page.  I would like to update  the picture using an update panel, but I dont see how I can trigger it from the content page.

    The master page image

    <asp:UpdatePanel ID="UpdatePanelParent" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional"> 
                      <ContentTemplate>
                  <asp:Image ID="iprofile" runat="server" BorderStyle="Solid" BorderColor="Gold" BorderWidth="1px" style="margin:20px;" />
                      </ContentTemplate>
                      </asp:UpdatePanel> 
    protected void btnclosepic_Click(object sender, EventArgs e)
        {
            UpdatePanel panel = (UpdatePanel)Master.FindControl("UpdatePanelParent");
            panel.Update();
    
        }

    This is my  attempt at triggering the update Panel - it doesnt work...

    Wednesday, April 2, 2014 7:20 PM

Answers

  • User1208776063 posted

    dieseldave

    I would like to update  the picture using an update panel, but I dont see how I can trigger it from the content page.

    One simple solution would be removing update mode

    <asp:UpdatePanel ID="UpdatePanelParent" runat="server">
        <ContentTemplate>
            <asp:Image ID="iprofile" runat="server" BorderStyle="Solid" BorderColor="Gold" BorderWidth="1px" Style="margin20px;" />
        </ContentTemplate>
    </asp:UpdatePanel>

    content page:

    (Master.FindControl("iprofile"as Image).ImageUrl = "Image url from content page";
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 2, 2014 7:27 PM

All replies

  • User1208776063 posted

    dieseldave

    I would like to update  the picture using an update panel, but I dont see how I can trigger it from the content page.

    One simple solution would be removing update mode

    <asp:UpdatePanel ID="UpdatePanelParent" runat="server">
        <ContentTemplate>
            <asp:Image ID="iprofile" runat="server" BorderStyle="Solid" BorderColor="Gold" BorderWidth="1px" Style="margin20px;" />
        </ContentTemplate>
    </asp:UpdatePanel>

    content page:

    (Master.FindControl("iprofile"as Image).ImageUrl = "Image url from content page";
    
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 2, 2014 7:27 PM
  • User-962670764 posted

    that returns an error -'Cannot convert type 'System.Web.UI.Control' to 'Image''

    Wednesday, April 2, 2014 9:40 PM
  • User1208776063 posted

    It seems like you are using System.Drawing in the page class. Make sure that proper type is used

     (Master.FindControl("iprofile"as System.Web.UI.WebControls.Image).ImageUrl = "Image url from content page";
    Wednesday, April 2, 2014 9:53 PM
  • User-962670764 posted

    OK I get no errrors, but the image on the master page is not updated. I have to leave the page and re-enter , so when it does postback it works, but it is not getting an asynch postback.

    (Master.FindControl("iprofile") as System.Web.UI.WebControls.Image).ImageUrl = filepath;

    Friday, April 4, 2014 10:27 PM