简体   繁体   中英

How to open a popup window in web forms without ajax modelpopupextender

I am a windows forms developer and learning asp.net. I want to open a form as show dialog, means if I click the button another form has to popup and user should not able to click the backgroung page(like alert or confirm but has to contain controls). It is possible with ajax popupextender control. I tried like

(Javascript)  function OpenPopup(ctrlid) {                  
              window.open("testControls.aspx?ctrlid=" + ctrlid,"List","left = 300, top=150,scrollbars=no,resizable=no,width=400,height=280");
              return false;
          }

and code behind

Button1.Attributes.Add("onclick", "javascript:return OpenPopup('" + this.txtlevel2.ClientID + "')");

It will open the another form but allows to click on behind page. Is there any posible to do this.

使用window.open()

 Response.Write("  <script language='javascript'> window.open('HomePage.aspx','','width=1020,Height=720,fullscreen=1,location=0,scrollbars=1,menubar=1,toolbar=1'); </script>");

Opening a popup window is nothing do with Ajax call it a javascript function you should use

window.open("http://www.w3schools.com")

follow the link( http://www.w3schools.com/jsref/met_win_open.asp ) for further details

You are looking for a modal popup (which requires the user to click a control within the popup to dismiss the popup), as opposed to a mode-less popup (which you can click around it to get it to hide). The ASP.NET AJAX PopupExtender is a mode-less popup.

Try the ASP.NET AJAX ModalPopupExtender , like this:

<ajaxToolkit:ModalPopupExtender ID="MPE" runat="server"
                                TargetControlID="LinkButton1"
                                PopupControlID="Panel1"
                                BackgroundCssClass="modalBackground" 
                                DropShadow="true" 
                                OkControlID="OkButton" 
                                OnOkScript="onOk()"
                                CancelControlID="CancelButton" 
                                PopupDragHandleControlID="Panel3" >
    <Animations>
        <OnShowing> ..  </OnShowing>
        <OnShown>   ..  </OnShown>    
        <OnHiding>  ..  </OnHiding>            
        <OnHidden>  ..  </OnHidden>            
    </Animations>
</ajaxToolkit:ModalPopupExtender>

Look at ModalPopup Demonstration for a demonstration of the effect by clicking on the various links on the page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM