如何在ASP.NET中创建Modal Popup [英] How to create Modal Popup wihin ASP.NET

查看:53
本文介绍了如何在ASP.NET中创建Modal Popup的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我的问题很简单(我认为),如何创建模态弹出窗口并将参数传递给弹出页面Page_Load()事件以在SQL查询中使用?我使用以下Java函数打开窗口并将一些数据传递到新窗口:

So my question is simple (I think), How do I create a Modal Popup window and pass parameters to the popups Page_Load() event to use in a SQL query? I have used the following java function to open the window and pass some data to the new window:

function OpenSearchResults() {
         var ParamName = document.getElementById("textName").value;
               var myArgs = new Array(ParamName);
               var WinSettings = "center:yes;resizable:no;dialogHeight:450px; dialogWidth:270px"
               var myArgs = window.showModalDialog("./SearchResults.aspx", myArgs, WinSettings);
               if (myArgs == null) {
                   window.alert("No name has been selected");
               }
               else {
                   document.getElementById("textName").value = myArgs[0].toString();
               }

And the following in the new window:
        
Function Initialize() {
            var paramName = "NAME";
            var myArgs = new Array(paramName);
            myArgs = window.dialogArguments;
            document.getElementById("Hidden1").value = myArgs[0].toString();
        }

对于页面加载,我正在使用< body onload =初始化">

我打算只将参数放在隐藏字段中,然后使用该值构建查询,但是问题在于,由于此操作在构建页面之前执行,因此尚未创建Hidden1对象,因此代码崩溃.如果我尝试从Page_Load调用Initialize函数,它将等待直到页面完全加载后再执行该函数,并且由于Page_Load事件已经触发,所以我无法触发查询.

For the page load I am using <body onload=" Initialize">

I was planning on just putting the parameter in a hidden field and using that value to build my query however the problem is that since this executes before the page is built the Hidden1 object has not yet been created so the code crashes. If I try and call the Initialize function from Page_Load it waits till the page is completely loaded before executing the function and since the Page_Load event has already fired I can’t trigger my query.

推荐答案

将所需的值作为查询字符串参数传递到用于弹出窗口的页面.

顺便说一句,创建和管理弹出窗口的方法要简单得多,例如JQuery UI或ASP.NET AJAX modalpopup扩展程序.
Pass the values needed to as query string parameters to the page being used for the popup.

BTW, there are far easier methods to create and manage popups, such as JQuery UI or ASP.NET AJAX modalpopup extender.



您可以使用jQuery UI来获取模式弹出窗口,
需要实现json2.js文件来解析您的数据.
因为您说要传递Query的参数,所以可以通过使用客户端实现方案来完成任务.
步骤是
1.首先准备好要弹出的面板
2.使用[PageMethods]或[WebMethod]将参数传递给SQL查询. 3.提取数据
4.使用[WebMethod]的Success部分,您可以用数据填充弹出控件.
Hi,
You can get modal popup using jQuery UI,
need to implement json2.js file for parsing your data.
Because you are saying to pass parameters for the Query for that you can make your task done by implementing scenario using client side.
Steps are
1. First prepare your panel for popup
2. Pass your parameters towards SQL Query using [PageMethods] or [WebMethod]
3. Fetch your data
4. With Success part of the [WebMethod] you can fill your popup controls with data.


(函数() { // 显示弹出窗口


这篇关于如何在ASP.NET中创建Modal Popup的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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