Ho to set wallpaper on desktop in code behind

  1. #1

    Ho to set wallpaper on desktop in code behind



    Hi

    How can I set the wallpaper on the desktop in code/AjaxMetod

    e.g something like this:
    [AjaxMethod]
    public void SaveSettings()
    {
        this.MyDesktop.Wallpaper = this.cbWallpaper.SelectedItem.Value;
    }
    Kind regards
    Steen
  2. #2

    RE: Ho to set wallpaper on desktop in code behind

    Hi,

    We added support to change Wallpaper during AjaxEvent.
    Till new release you can use next code:


    MyDesktop.AddScript("{0}.getDesktop().setWallpaper ({1});", MyDesktop.ClientID, url); 


    Vladimir Shcheglov
    Sr. Developer
  3. #3

    RE: Ho to set wallpaper on desktop in code behind

    Thanks for the reply, but I seem to miss something as this just gives an JavaScript error:

    [AjaxMethod]
    public void SaveSettings()
    {
        mwSettings settings = new mwSettings();
        MyDesktop.AddScript("{0}.getDesktop().setWallpaper({1});", MyDesktop.ClientID, "images/wallpaper/img16.jpg"); 
        
    }
    JavaScript error is: 'images' is not defined
  4. #4

    RE: Ho to set wallpaper on desktop in code behind

    Hi,

    you should add quoutes or JSON.Serialize


    [AjaxMethod]
    public void SaveSettings()
    {
        mwSettings settings = new mwSettings();
        MyDesktop.AddScript("{0}.getDesktop().setWallpaper ('{1}');", MyDesktop.ClientID, "images/wallpaper/img16.jpg"); 
        



    or


    [AjaxMethod]
    public void SaveSettings()
    {
        mwSettings settings = new mwSettings();
        MyDesktop.AddScript("{0}.getDesktop().setWallpaper ({1});", MyDesktop.ClientID, JSON.Serialize("images/wallpaper/img16.jpg")); 
        
    }


    Vladimir Shcheglov
    Sr. Developer
  5. #5

    RE: Ho to set wallpaper on desktop in code behind

    Sorry, my mistake... I just copied your code without thinking :)
    Now it works, thanks !

Similar Threads

  1. Desktop: wallpaper problem
    By heysol in forum 1.x Help
    Replies: 1
    Last Post: Dec 29, 2017, 3:52 PM
  2. Stretching desktop wallpaper
    By feanor91 in forum 1.x Help
    Replies: 0
    Last Post: Jan 19, 2012, 10:15 AM
  3. Wallpaper halts the Desktop?
    By rlasker3 in forum Bugs
    Replies: 0
    Last Post: Feb 15, 2010, 12:56 PM
  4. Desktop wallpaper cannot load
    By Nime in forum 1.x Help
    Replies: 1
    Last Post: Jan 15, 2009, 11:49 AM
  5. [CLOSED] ext:Desktop - changing Wallpaper via JS
    By Emre in forum 1.x Premium Help
    Replies: 4
    Last Post: Dec 29, 2008, 11:49 AM

Posting Permissions