4

I am building a Sheer UI dialog following examples from the web. I keep seeing this throughout various examples:

string controlId = args.Parameters["controlid"];
SheerResponse.Eval("scSetHtmlValue('" + controlId + "', false, true)");

What exactly does this do?

1 Answer 1

4

Its a sheer UI functionality that usually used if you are building new custom field and you want that field to have its own edit interface in Page editor, or you want to extend one of default sitecore fields.

For example let say you want to add custom button next to "Single Text Line" field in page editor, that simply clears the content of your field.

This code would be added to your custom "Web Edit Command" class to do that:

   //Set Html Value to be empty string
   SheerResponse.SetAttribute("scHtmlValue", "value", String.Empty);
   //Set Raw value to empty string
   SheerResponse.SetAttribute("scPlainValue", "value", String.Empty);

   //This line of code will not save the changed value back into the item (Empty string),
   // instead it will let page editor know that this field value has bee changed, 
   // and once the user hits save, it will be stored back into the item
   SheerResponse.Eval("scSetHtmlValue('" + args.Parameters["controlid"] + "')");

So, as you can see, That function will inform Page editor that a change has been made to this field, And PE will store that change once the user clicks save.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.