Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Diogo 9 posts 40 karma points
    May 13, 2014 @ 14:01
    Diogo
    0

    How can i edit/save with c# a property witch is sql:autocomplete

    Hey all, im new to umbraco so i am kinda "lost" :( .

    Few weeks ago i started a project with umbraco and c# and now im stuck. I can save and edit any other property values by doing this:

    member.getproperty("alias").value= //something

    or

    member.getproperty("alias").value.ToString()  to read it.

    but now i need to work with a property witch is autocomplete and i simple cant do nothing with it. Basicly what i get when i do Response.Write(member.getproperty("myList1-Foundations").value.ToString()) to read it and check it, is nothing (that we can see in browser) but if i right click on the mouse and go to view page source i got something like this :

    <sqlautocomplete>

    <item text="A. P. Møllers Fond for islandske studerende ved de højere Læreanstalter" value="1279">

    <item text="Aktive Unge - Ungdomsudvekslinger i nabopartnerlande" value="1358">

    </item>

    </item>

    </sqlautocomplete>

     

    But i cant do nothing with this , at least as far i my umbraco experience goes. What i need to do is basicly when edit add new item to this  property . If anyone could help i would appreciate . Thanks guys

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    May 13, 2014 @ 15:10
    Jan Skovgaard
    0

    Hi Diogo and welcome to our :)

    Can you tell us, which version of Umbraco you're using? And I'm guessing you're using uComponents since you're referring to the sql autocomplete box as well?

    /Jan

  • Hendy Racher 863 posts 3849 karma points MVP 2x admin c-trib
    May 13, 2014 @ 15:11
    Hendy Racher
    100

    Hi Diogo,

    Sql AutoComplete saves its data in an xml fragment as you've described above - to manually add an item you'll need to add an node into that xml fragment, and then resave the whole fragment.

    eg (this hasn't been tested !)

    using System.Xml.Linq;        
    
    XDocument xDocument = XDocument.Parse(member.getproperty("alias").value.ToString());
    
    xDocument.Root.Add(new XElement(
                                "Item", 
                                new XAttribute("Text", "some text"),
                                new XAttribute("Value", "some value")));
    
    member.getproperty("alias").value = xDocument.ToString();
    
    
    What's your use-case, perhaps there's another way without having to manipulate the xml ?
    HTH,
    Hendy

     

     

  • Diogo 9 posts 40 karma points
    May 13, 2014 @ 15:20
    Diogo
    1

    Hey Jan Skovgaard , and thanks for the welcome's :) Im using V6.1 

     

    Hendy Racher you are the MAN !

    WOW Thankssssssssss ! thankssssssssss ! U cant imagine how many hours i "wasted" in order to get this working :O 

     

    So simple as that , really THANK YOU SIR ! :D

  • Diogo 9 posts 40 karma points
    May 13, 2014 @ 15:26
    Diogo
    0

    Guys i dont want to "abuse" from your help , but in my case im using this to save list's with favorites but 1 member can have more than 1 list. So when they want to create another list, i need to create a new property to the member? cause in this case im just editing a property i already created "myList1-Foundations" but if the user wants to create(and he have that option) "myList2-Foundations" i have to create dynamicly the property ? how? :S

     In the backoffice is something like this :

     

    Thanks for the effort and sorry for my bad english (im from Portugal :D)

Please Sign in or register to post replies

Write your reply to:

Draft