This is a migrated thread and some comments may be shown as answers.

Update backgroundimage panel with javascript

3 Answers 64 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Fabio Cirillo
Top achievements
Rank 1
Fabio Cirillo asked on 18 Dec 2012, 01:15 AM
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


3 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Dec 2012, 04:48 AM
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.
0
Fabio Cirillo
Top achievements
Rank 1
answered on 18 Dec 2012, 08:15 AM
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 "("? 
0
Princy
Top achievements
Rank 2
answered on 19 Dec 2012, 05:20 AM
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.
Tags
General Discussions
Asked by
Fabio Cirillo
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Fabio Cirillo
Top achievements
Rank 1
Share this question
or