如何从 ASP 代码隐藏中修改模式弹出窗口而不是让它关闭?

发布于 2024-09-02 05:25:24 字数 457 浏览 6 评论 0原文

我正在使用 SimpleModal 在 ASP.net 应用程序上创建弹出窗口。 “确定”按钮调用服务器端函数 - 根据该函数的结果,我想修改弹出窗口(使某些内容可见等),而不是让它关闭。如果这太困难,我想再次打开弹出窗口,而用户不必重新单击任何内容。我只是不确定最好的方法是什么。

目前弹出窗口中的“确定”按钮看起来像这样:

<asp:ImageButton ID="submitInfoBtn" OnClick="btnSubmitInfo_Click"
           ImageUrl="css/assets/btn_ok.png" runat="server"/>  

并且没有任何定义告诉“确定”按钮应该关闭弹出窗口(“取消”按钮有 class="simplemodal-close",所以我希望它能做到这一点,但不是“确定”按钮)-有人对解决此问题的最佳方法有任何想法吗?提前致谢!!

I'm using SimpleModal to create a popup on an ASP.net application. The OK button calls a server-side function - and based on the resulta of that function I'd like to modify the popup (make some things visible, etc.) instead of letting it close. If that's too difficult, I'd like to open the popup again without the user having to re-click on anything. I'm just not sure what the best way to do this is.

Currently the OK button in the popup looks like this:

<asp:ImageButton ID="submitInfoBtn" OnClick="btnSubmitInfo_Click"
           ImageUrl="css/assets/btn_ok.png" runat="server"/>  

and there is nothing defined that tells anything that the OK button should close the popup (the Cancel button has class="simplemodal-close", so I would expect it to do just that, but not the OK button) - anyone have any ideas on the best way through this? Thanks in advance!!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

顾北清歌寒 2024-09-09 05:25:25

这并不难,请看我的弹出窗口代码。弹出的窗口中有一个“确定”按钮,有时点击“确定”会修改弹出窗口,有时点击会关闭窗口,是不是我理解有误?

void OK_click(object sender, EventArgs e)
{
   try
   {
      if (DataIsValid())
      {
        Save();
        this.Page.ClientScript.RegisterStartupScript(typeof(Page), "closeWindow", "<script type='text/javascript'>self.opener=null; self.close();</script>");
      }
      else ErrorLabel.Visible = true;
   }
   catch { ErrorLabel.Visible = true; }

}

It's not so difficult, see my code of the pop up window. There is an OK button in the pop up, sometimes clicking OK will modify the pop up window, sometimes clicking will close the window, do I have a misunderstanding?

void OK_click(object sender, EventArgs e)
{
   try
   {
      if (DataIsValid())
      {
        Save();
        this.Page.ClientScript.RegisterStartupScript(typeof(Page), "closeWindow", "<script type='text/javascript'>self.opener=null; self.close();</script>");
      }
      else ErrorLabel.Visible = true;
   }
   catch { ErrorLabel.Visible = true; }

}
疾风者 2024-09-09 05:25:25

您需要使用 SimpleModal onShow 回调绑定到“确定”按钮,发出 ajax 请求,然后检查响应并显示新内容。

您不应使用 onClose 回调,因为它仅用于动画关闭或任何清理。当您准备好时,您可以使用 $.modal.close(); 以编程方式关闭对话框。

它将涉及检查返回内容的尺寸并相应地调整模态尺寸。

看看 flickr 徽章查看器演示 (http://www.ericmmartin.com/projects /simplemodal-demos/)作为我正在讨论的示例。

You'll want to use the SimpleModal onShow callback to bind to the OK button, make the ajax request, then check the response and show the new content.

You shouldn't use the onClose callback because it's just for animating the close or any cleanup. You can programatically close the dialog when you are ready with $.modal.close();

It will involve checking the dimensions of the returned content and adjusting the modal dimensions accordingly.

Have a look at the flickr badge viewer demo (http://www.ericmmartin.com/projects/simplemodal-demos/) for an example of what I'm talking about.

枯寂 2024-09-09 05:25:24

您需要为按钮设置 Javascript 处理程序,返回 false。看...
如何禁用 asp 按钮上的回发

请注意返回 false 。这将防止回发。

现在,您可以在 Javascript 按钮处理程序中使用 Ajax 获取所需的任何服务器数据,并使用 JQuery 修改 Popup。

顺便说一下,您还可以使用 JQuery UI 对话框 作为模式弹出窗口。使用它你可能会得到更多的支持。

You need to set the Javascript handler for the button with return false. See...
How to disable postback on an asp Button

Notice the return false. This will prevent a Postback.

Now you can get any server data that you need using Ajax in your Javascript button handler and use JQuery to modify your Popup.

By the way, you can also use JQuery UI Dialog for modal popups. You may have much more support using that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文