The official release of Ext.NET Mobile is now available. Ext.NET Mobile is an ASP.NET component framework for building Phone and Tablet specific mobile web applications. Read More

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

Posting Permissions

Subscribe now to get the latest Ext.NET happenings in our newsletter.