`
chenxueyong
  • 浏览: 336164 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
社区版块
存档分类
最新评论

模态窗口

阅读更多

.模态窗口的打开,model window open
2.模态窗口的关闭,model window close
3.模态窗口的传递参数,model window  get valuse
4.其他....,other ..


1.window.showModalDialog("DialogPage.aspx","newwin","dialogHeight: 200px; dialogWidth: 150px; dialogTop: 458px; dialogLeft: 166px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: Yes;");

2.window.close();

3.传值
ParentPage.aspx:
window.showModalDialog("DialogPage.aspx?para1=aaa&para2=bbb");

DialogPage.aspx:
string str1=Request.QueryString["para1"].toString();
string str2=Request.QueryString["para2"].toString();

返回值
DialogPage.aspx:
window.returnValue="aaa";   //返回aaa

ParentPage.aspx:
var str=window.showModalDialog("DialogPage.aspx");   //这样可以得到模态窗口的返回值aaa

在实际应用中可能如下:在DialogPage.aspx页面中一按扭响应事件如下:

        //确定事件处理程序
        private void ibtnOK_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        
{
            DataTable dt
=parameters.ParameterTable;
            
string name=parameters.STRTableName;
            
string strSearch="";
            
            
//返回拼接参数条件
            strSearch=ReturnParaValues(dt);
            
if(strSearch!="")
            
{
                strSearch
=" and 1=1 "+strSearch;
            }


            
//执行JavaScript脚本
            StringBuilder sb = new StringBuilder();
            
if (!this.Page.IsClientScriptBlockRegistered("GoExactSearchView")) 
            
{
                sb.Append(
"<script language='javascript'>\n")
                    .Append(
"window.returnValue =").Append("window.dialogArguments+\" "+strSearch).Append("\";\n")
                    .Append(
"window.close();\n")
                    .Append(
"</script>\n");
                
this.Page.RegisterClientScriptBlock("GoExactSearchView",sb.ToString());
            }

        }

上述程序运行时的一个示例监视为:

strsearch = " and 1=1  and TempColumn63467 like '%CKD康明斯C300 20 (欧II)%'"

<script language='javascript'>
window.returnValue 
=window.dialogArguments+"  and 1=1  and TempColumn63467 like '%CKD康明斯C300 20 (欧II)%'";
window.close();
</script>
<!--注意window.dialogArguments 的作用:在下面讲到-->


这样当单击提交时,会将处理后的结果strSearch返回!并自动关闭该模态页面!
而父页面处理如下:

 

//以有模式打开参数过滤窗口 冯岩 2007-04-23 e-works
function OpenParaListWin(Url,strArgs,CetValueCtlID)
{
    document.getElementById(
"IframeSearch").src = Url;
    document.getElementById(
"IframeSearch").style.display = "inline"
    
var resultValue=window.showModalDialog(Url,strArgs,'dialogWidth=500px;dialogHeight=500px;help:no;status:no; ');  
    
/**//*注意其中第二个参数strArgs,其作用是在操作完打开的模态窗口后,可以再将此参数返回给本页面,如何获取,即利用上面的window.dialogArguments属性,即得到strArgs的值!这种方式有时比URL中传参更好!不过window.dialogArguments只适用于mode和modeless窗口中*/
    
if(resultValue!=undefined)
    
{
         
//window.alert(resultValue);
        document.getElementById(CetValueCtlID).value=resultValue;//处理模态窗口返回值
        document.getElementById('Form1').submit();                //自动提交本aspx页面,以更新结果!
    }

    
return false;
}

上述JS函数也是父窗口 单击Button  click的响应处理事件!如果返回有结果则会自动更新本页面!

4.
aspx页面在showmodeldialog情况下为什么一提交就重新打开一个页面?
showmodaldialog打开的页面中在<head></head>之间加入一行:<base target="_self">

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics