Update backgroundimage panel with javascript

4 posts, 0 answers
  1. Fabio Cirillo
    Fabio Cirillo avatar
    181 posts
    Member since:
    Jan 2010

    Posted 17 Dec 2012 Link to this post

    Hi,

    i've a page asp with a panel object. With this panel i msut update backgroundimage with javascript function.
    I call the radwindow with this code:

                     function openRadWindowCard() {
                         var panel;
                         panel = document.getElementById('<%= Panel1.ClientID %>');
                         radopen("UploadImgCard.aspx?urlcard=" + panel.style.backgroundImage, "RadWindowLoadcard");
                     }
     
                            <telerik:RadWindow ID="RadWindowLoadcard" runat="server"
                                ShowContentDuringLoad="false" Width="393px"
                                Height="300px" Title="Caricamento immagine biglietto" Behaviors="None"
                                MaxHeight="300px" MaxWidth="400px" Modal="True" IconUrl="/image/iconlogo.png"
                                OnClientClose="RefreshBackgroud" VisibleStatusbar="False" Skin="Simple" ReloadOnShow="True">
                            </telerik:RadWindow>
     
    <asp:LinkButton ID="Load_sfondo" runat="server" ForeColor="#D5842B" OnClientClick="openRadWindowCard(); return false;">Carica sfondo personalizzato</asp:LinkButton>

    now when close the radwindow i must trasfer the path image to master page and refresh automatic the panel's backgroundimage.

    this code is:
    function RefreshBackgroud(sender, eventArgs) {
        var strimage = eventArgs.get_argument();
        var panel = document.getElementById('<%= Panel1.ClientID %>');
        panel.style.backgroundImage = strimage;
        return false;
    }

    and this code into radwindos is:

    <script type="text/javascript">
        function GetRadWindow() {
            var oWindow = null;
            if (window.radWindow) oWindow = window.radWindow;
            else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
            return oWindow;
        }
        function Close(argument) {
            GetRadWindow().close(argument);
        }
        </script>
    Protected Sub Imgbtnesci_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles Imgbtnesci.Click
        ScriptManager.RegisterStartupScript(Page, Me.Page.GetType(), "closeWindow", "Close('" & ViewState("DirImage") & "');", True)
    End Sub

    but the backgroudiamge dont update..i see with debug step to step that che variable strimage has the path correct but dont update in this code

    panel.style.backgroundImage


    how do you it?

    bye


  2. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 17 Dec 2012 Link to this post

    Hi Fabio Cirillo,

    Please make sure that you are setting the backgroundImage as follows.

    JS:
    var panel = document.getElementById("Panel1");
    panel.style.backgroundImage = "url('../Images/image1.jpg')";

    Please elaborate your scenario if it doesn't helps.

    Regards,
    Princy.
  3. Fabio Cirillo
    Fabio Cirillo avatar
    181 posts
    Member since:
    Jan 2010

    Posted 18 Dec 2012 Link to this post

    I saw that when debugging the code is executed the function, the variable strimage has the following value: "url (" / image / image_card / sfondo.png ")", it is normal to have the "" inside "("? 
  4. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 18 Dec 2012 Link to this post

    Hi,

    Please try changing the imageurl as follows and let me know whether it helps.

    JS:
    var panel = document.getElementById("Panel1");
    panel.style.backgroundImage = "url ('/ image / image_card / sfondo.png ')";

    Hope this helps.

    Regards,
    Princy.
Back to Top