如何在ASP.NET Web应用程序中生成模式弹出窗口? [英] How do I generate a modal popup in an ASP.NET Web Application?

查看:62
本文介绍了如何在ASP.NET Web应用程序中生成模式弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试一天半没有运气,所以请善待。我去过许多关于这个问题的解决方案中引用的所有网站,但我仍然被卡住了。



我有一个C#Web应用程序(当然)建立一个aspx页面。单击按钮后,我想显示包含各种控件的另一个页面的模式弹出窗口。数据必须传递到模态窗口以及模态窗口。



我已经下载了AjaxControlToolkit并查看了文档,但我仍然无法弄清楚如何做到这一点。我猜它与ModalPopupExtender有关,但这只是一个*扩展器*,而不是一个控件。



我也试过了 - 盒子Ajax(例如,GET等),但没有运气。



有人提供一个例子说明如何从我的Web应用程序生成模态弹出窗口?我再也不能再把头靠在墙上了。 (注意:我不关心它是如何完成的 - Ajax,AjaxControlToolkit,JavaScript,等等。我只需要让它工作。)



谢谢。

解决方案

我必须在我的网站上使用相同的东西。好吧,你可以使用ajax模型弹出窗口或颜色框Jquery。

如果有帮助,我可以提供我的代码示例。



1)ModelPopup示例:

 <   form     id   =  form1    runat   = 服务器 >  
< div >
< asp:ToolkitScriptManager ID = ToolkitScriptManager1 runat = 服务器 >
< / asp:ToolkitScriptManager >
< asp:按钮 ID = Button1 runat = server < span class =code-attribute> 文本 = 填写表格 / >
< asp:ModalPopupExtender ID = ModalPopupExtender1 runat = server < span class =code-attribute> CancelControlID = Button2 TargetControlID = Button1 PopupControlID = Panel1 >
< / asp:ModalPopupExtender >
< asp:面板 ID = Panel1 runat = server CssClass = 弹出 align = center < span class =code-attribute> style = display:none >
< iframe style = width:350px ;高度:300px; id = irm1 src < span class =code-keyword> = test2.aspx runat = server > < / iframe >
< br / >
< asp:按钮 ID = Button2 runat = 服务器 正文 = 关闭 / >
< / asp:Panel >
< ; / div >
< / form >



这将显示test2.aspx页面为modelpopup中的弹出窗口。



2)使用Colorbox Jquery

 <   html     xmlns   =  http://www.w3.org/1999 / xhtml >  
< head runat = server >
< ; title > < / title >
< link rel = 样式表 href = http://www.formmail-maker.com /var/demo/jquery-popup-form/colorbox.css\" / >
< script < span class =code-attribute>
src = https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js > < / script >
< script src = http: //www.formmail-maker.com/var/demo/jquery-popup-form/jquery.colorbox-min.js\"> < / script >
< script >

(document).ready(function(){


(。iframe)。colorbox({iframe:true,fastIframe:false,width: 450px,身高:480px,过渡:淡出,滚动:虚假});
});
< / script >
< / head >
< body > ;
< 表格 id = form1 runat = server >
< div >
< a class =' iframe' href = Default.aspx > 与我们联系< / a >
< / div >
< / form >
< / body >
< / html >



这将在弹出窗口显示Default.aspx。



这两个代码对我有用,我希望你能找到这个。如果没有,请告诉我。 :)


I've been trying things for a day and a half with no luck, so please be kind. I've been to all the websites referenced in many of the solutions about this question, but I am still stuck.

I've got a C# Web Application that (of course) puts up an aspx page. Upon a button click I want to display a modal popup of another page that contains various controls. Data must be passed to the modal window as well as from the modal window.

I've downloaded the AjaxControlToolkit and looked at the documentation, but I still can't figure out how to do this. I'm guessing it has something to do with the ModalPopupExtender, but that's just an *extender*, not a control.

I've also tried out-of-the-box Ajax (e.g., "GET", etc.), but no luck.

Can someone please provide an example of how to generate a modal popup from my web application? I can't take another day of bashing my head against the wall. (Note: I don't care how it's done -- Ajax, the AjaxControlToolkit, JavaScript, whatever. I just need to get this to work.)

Thank you.

解决方案

I had to use the same thing in my website. Well, You may use a ajax model popup or colorbox Jquery for this.
I can provide you my code sample, if it helps.

1) ModelPopup Example:

<form id="form1" runat="server">
    <div>
        <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
        </asp:ToolkitScriptManager>
        <asp:Button ID="Button1" runat="server" Text="fill form" />
        <asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" CancelControlID="Button2" TargetControlID="Button1" PopupControlID="Panel1">
        </asp:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" CssClass="Popup" align="center" style = "display:none">
        <iframe style=" width: 350px; height: 300px;" id="irm1" src="test2.aspx" runat="server"></iframe>
        <br/>
        <asp:Button ID="Button2" runat="server" Text="Close" />
        </asp:Panel>
    </div>
    </form>


this will show you test2.aspx page as popup in modelpopup.

2) using Colorbox Jquery

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
   <link rel="stylesheet" href="http://www.formmail-maker.com/var/demo/jquery-popup-form/colorbox.css" />
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
        <script src="http://www.formmail-maker.com/var/demo/jquery-popup-form/jquery.colorbox-min.js"></script>
        <script>


(document).ready(function () {


(".iframe").colorbox({ iframe: true, fastIframe: false, width: "450px", height: "480px", transition: "fade", scrolling: false }); }); </script> </head> <body> <form id="form1" runat="server"> <div> <a class='iframe' href="Default.aspx">Contact Us</a> </div> </form> </body> </html>


this will show you Default.aspx in pop-up.

Both codes work for me and I hope you were looking for this. If not then let me know. :)


这篇关于如何在ASP.NET Web应用程序中生成模式弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆