好的......在Sitecore的支持幫助下,我終於得到了這個問題的答案。爲了讓頁面編輯器爲字段獲取新值,需要調用Sitecore.WebEdit.setFieldValue()javascript函數。這將創建一個隱藏的輸入字段,PageEditor隨後在單擊保存或保存/關閉按鈕時讀取。
//RenderItem is the item in question, DropListField is the string name of
//the target Droplist field we want rendered
string itemID = RenderItem.ID.ToShortID().ToString();
string fieldID = RenderItem.Fields[DropListField].ID.ToShortID().ToString();
string language = RenderItem.Language.ToString();
string version = RenderItem.Version.ToString();
string revision = RenderItem[FieldIDs.Revision].Replace("-", string.Empty);
ddlList.Attributes.Add("onchange", string.Format("var ddl = getElementById('{5}');var itemURI = new Sitecore.ItemUri('{0}','{1}','{2}','{3}');Sitecore.WebEdit.setFieldValue(itemURI,'{4}',ddl.options[ddl.selectedIndex].value);",itemID,language,version,revision,fieldID,ddlList.ClientID));
所以,基本上我們只需添加一個客戶端平變化處理程序調用該Sitecore的js函數DropDownList的。注:我相信這需要Sitecore 6.2。
不幸的是,這與我所需要的完全相反。我想在編輯項目的Droplist字段時顯示一個asp:DropDownList。這樣用戶就可以從下拉菜單中選擇一個新的值,就像在Content Editor中一樣,不用離開頁面編輯器。 – Bryan 2010-01-13 20:51:39