首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SheerResponse ShowModalDialog不返回结果

SheerResponse ShowModalDialog不返回结果
EN

Stack Overflow用户
提问于 2015-10-13 17:43:30
回答 2查看 742关注 0票数 2

我正在使用sitecore 8更新2。我正在扩展TreelistEx字段。

用户将看到一个模式对话框(由Sheerresponse使用QuickContact.html创建)。在这里,用户可以填写4个字段。当用户单击"OK“时,这些字段的值被保存到一个对象中。我想返回这个对象/值。然而,我还没有找到实现这一点的方法。

( ClientPipelineArgs永远不会返回任何结果)

代码语言:javascript
复制
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

代码语言:javascript
复制
<!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>
EN

回答 2

Stack Overflow用户

发布于 2016-09-06 17:07:31

尝试在JavaScript中使用window.top.returnValue = returnVal;设置结果值,并使用args.Result在我们的C#代码中读取它。这对我很有效。

票数 1
EN

Stack Overflow用户

发布于 2015-10-14 20:00:55

我真的没有找到一个合法的解决这个问题的方法。我确实通过将我的结果写入coockie并在服务器端读取它(后来将其删除)来解决它。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33099339

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档