我正在使用sitecore 8更新2。我正在扩展TreelistEx字段。
用户将看到一个模式对话框(由Sheerresponse使用QuickContact.html创建)。在这里,用户可以填写4个字段。当用户单击"OK“时,这些字段的值被保存到一个对象中。我想返回这个对象/值。然而,我还没有找到实现这一点的方法。
( ClientPipelineArgs永远不会返回任何结果)
namespace be.absi.kbs.extensions
{
class AbsiTreeListEx : TreelistEx, IMessageHandler
{
void IMessageHandler.HandleMessage(Message message)
{
if (message == null)
{ return; }
if (message["id"] == null)
{ return; }
if (!message["id"].Equals(ID))
{ return; }
var fieldInfo = _fieldInformation[message["id"]];
switch (message.Name)
{
case "treelist:edit":
var nvcEdit = new NameValueCollection { { "source", fieldInfo.Source } };
Sitecore.Context.ClientPage.Start(this, "Edit", nvcEdit);
break;
case "absitreelistex:absiquickadd":
var nvcQuickAdd = new NameValueCollection { { "clientFieldId", message["id"] } };
Sitecore.Context.ClientPage.Start(this, "QuickAddItem", nvcQuickAdd);
break;
}
}
protected void QuickAddItem(ClientPipelineArgs args)
{
if (args.IsPostBack)
{
// GET information from the QuickContact.html
}
else
{
var options = new ModalDialogOptions("/QuickContact.html")
{
Closable = true,
Response = true
};
SheerResponse.ShowModalDialog(options);
args.WaitForPostBack();
}
}
}
}QuickContact.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<base target="_self">
<title></title>
<script type="text/javascript">
function sendResponse()
{
var o = new Object();
o.forename = document.getElementById("FirstNameId").value;
o.surname = document.getElementById("LastNameId").value;
o.phone = document.getElementById("PhoneId").value;
o.mail = document.getElementById("MailId").value;
window.returnValue = o;
return o;
}
function OK()
{
var returnVal = sendResponse();
var jQueryResult = window.parent.$('.ui-dialog-content:visible');
self.returnValue = returnVal;
document.returnValue = returnVal;
window.returnValue = returnVal;
jQueryResult.dialog('close');
}
</script>
</head>
<body>
<label style="min-width: 80px;">First Name: </label><input type="text" id="FirstNameId" /><br />
<label style="min-width: 80px;">Last Name: </label><input type="text" id="LastNameId" /><br />
<label style="min-width: 80px;">Phone: </label><input type="text" id="PhoneId" /><br />
<label style="min-width: 80px;">Mail: </label><input type="text" id="MailId" /><br />
<br />
<input type="button" value="OK" onclick="OK()" />
</body>
</html>发布于 2016-09-06 17:07:31
尝试在JavaScript中使用window.top.returnValue = returnVal;设置结果值,并使用args.Result在我们的C#代码中读取它。这对我很有效。
发布于 2015-10-14 20:00:55
我真的没有找到一个合法的解决这个问题的方法。我确实通过将我的结果写入coockie并在服务器端读取它(后来将其删除)来解决它。
https://stackoverflow.com/questions/33099339
复制相似问题