0

I have a object defined in my C# code behind as

 public List<Dictionary<string, string>> attributesList
        {
            get;
            set;
        }

now I need to fill this object from Jquery That is, in my Jquery file I m getting certain values that I need to fill in this object. I am stuck on how to create a JSON object from the following code

selectedAttributes.each(function (key, value) {
                    var attributeName = value.attributes.title.value;
                    var attributeValue = $('#' + attributeName + ' option:selected').text();

                });

that can be supplied to the attributesList I need to put (attributeName, attributeValue) pair in the attributelist object

I know I am not clear enough in asking this question, but if any information is required please comment and I'll reply almost instantly.

1 Answer 1

1

A Dictionary would be just an object in JS. You're able to address the items within the dictionary by it's name.

 dic['name'] = 'value'; // valid
 dic.name = 'value'; // also valid
 var attrName = 'name';
 dic[attrName] ='value'; // also valid

That should be enough info to let you accomplish your task.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.