我如何使用新的页面弹出源创建一个弹出窗口? [英] How can I create a pop-up window using a new page as the pop-up source?

查看:116
本文介绍了我如何使用新的页面弹出源创建一个弹出窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想点击一个createbutton时,弹出一个面板上,我使用的是面板和添加面板里面的一些文本框和按钮。我能够在同一页面里createbutton为present设计它使弹出面板。我可以弹出一个单独的页面,使其弹出当我点击createbutton


解决方案

戈库尔,

是的,你可以把面板在一个单独的页面,并当您单击创建按钮,它出现。这里有一个替代的(不是我的最爱,但它不依赖于任何额外的东西,除了标准JavaScript):


  • 当你点击创建按钮打开一个新的浏览器正是调整以匹配面板大小的窗口。这可以用JavaScript很容易做到如下:


      

    <
      输入的onclick =JavaScript的:window.open('page.aspx','标题','状态= 0,工具栏= 0,宽度= 350,高度= 250');
      类型=按钮值=创建/>



  • 在你弹出包含该面板的页面(pagecontainingPanel.aspx - 根据我的例子),你可以有code,一旦你执行一些操作来关闭该窗口。例如,如果你有一个是应该的一些数据到数据库并保存复出到父网页上的按钮,你可以这样做:



  

{


  ///执行服务器端进程。如果成功执行关闭此窗口。
  保护无效btnSubmit_Click(对象发件人,EventArgs的发送)
  如果(EverythingOK)
        {
           StringBuilder的cstext2 =新的StringBuilder();
  cstext2.Append(<脚本类型= \\文/ JavaScript的\\>功能CloseMe(){);
  cstext2.Append(window.close()的;}&下; /);
  cstext2.Append(脚本>中);
  cs.RegisterStartupScript(cstype,csname2,cstext2.ToString(),FALSE);
        }    }

I want to pop up a panel when a "createbutton" is clicked, I am using a panel and adding some textbox and buttons inside the panel. I am able to make the pop up panel by designing it in the same page where the createbutton is present. can I make the pop up in a separate page and make it pop up when I click the createbutton

解决方案

Gokul,

Yes, you can put the panel in a separate page and make it appear when you click the create button. Here's one alternative (not my favorite but it doesn't depend on anything extra besides standard javascript):

  • When you click the "create button" open a new browser window resized exactly to match the panel's size. This can be done with javascript easily as follows:

    < input onclick="javascript:window.open('page.aspx','title','status=0,toolbar=0,width=350,height=250');" type="button" value="Create" />

  • On the page that you popped up containing the panel (pagecontainingPanel.aspx - according to my example), you can have code to close the window once you perform some action. For example, if you have a button that's supposed to save some data to the database and comeback to the parent page, you could do something like:

{

  ///Perform server side process. If successfully executed close this window. 
  protected void btnSubmit_Click(object sender, EventArgs e)
  if(EverythingOK) 
        { 
           StringBuilder cstext2 = new StringBuilder();
  cstext2.Append("<script type=\"text/javascript\"> function CloseMe() {");
  cstext2.Append("window.close();} </");
  cstext2.Append("script>");
  cs.RegisterStartupScript(cstype, csname2, cstext2.ToString(), false);
        } 

    }

这篇关于我如何使用新的页面弹出源创建一个弹出窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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