Asp.net 如何以模式弹出窗口的形式打开aspx页面
如何以模式弹出窗口的形式打开aspx页面Asp.net 如何以模式弹出窗口的形式打开aspx页面,asp.net,vb.net,modal-dialog,Asp.net,Vb.net,Modal Dialog,如何以模式弹出窗口的形式打开aspx页面 Test.aspx应该像模式弹出窗口一样打开 让Test1.aspx有一个按钮。单击后,它将以模式弹出窗口的形式填充Test.aspx页面 这是我的按钮: <asp:Button ID="Button1" runat="server" Text="Fill Form in Popup" /> 注意:Test.aspx:Normal aspx页面,但Test1.aspx:Parent页面包含母版页。使用ClientScript.Regis
<asp:Button ID="Button1" runat="server" Text="Fill Form in Popup" />
注意:Test.aspx:Normal aspx页面,但Test1.aspx:Parent页面包含母版页。使用
ClientScript.RegisterStartupScript
,请尝试以下操作
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim query As String = "test.aspx"
Dim newWin As String = "window.open('" & query & "');"
ClientScript.RegisterStartupScript(Me.GetType(), "pop", newWin, True)
End Sub
您可以使用如下所示的模式弹出扩展程序
<cc1:ModalPopupExtender ID="mp1" runat="server" PopupControlID="Panl1" TargetControlID="Button1"
CancelControlID="Button2" BackgroundCssClass="Background">
</cc1:ModalPopupExtender>
参考:
或者可以使用jquery打开asp.net的模式对话框,类似于
$(document).on("click", "#LoadDialogButton", function () {
var url = "DialogContentPage.aspx";
var divId = " #MainContentDiv";
var q1 = "?inp1=" + $("#Input1").val();
var q2 = "&inp2=" + $("#Input2").val();
url = url + q1 + q2 + divId; //url in the form 'DialogContentPage.aspx?inp1=xx&inp2=yy #MainContentDiv'
$('<div id=DialogDiv>').dialog("destroy");
$('<div id=DialogDiv>').dialog({
dialogClass: 'DynamicDialogStyle',
modal: true,
open: function () {
$(this).load(url);
},
close: function (e) {
$(this).empty();
$(this).dialog('destroy');
},
height: 350,
width: 540,
title: 'Dynamic Dialog'
});
$(文档)。在(“单击”、“#加载对话框按钮”上,函数(){
var url=“DialogContentPage.aspx”;
var divId=“#MainContentDiv”;
var q1=“?inp1=“+$(“#Input1”).val();
var q2=“&inp2=“+$(“#Input2”).val();
url=url+q1+q2+divId;//格式为'DialogContentPage.aspx?inp1=xx&inp2=yy#MainContentDiv'的url
$('').dialog(“销毁”);
$('')。对话框({
dialogClass:'DynamicDialogStyle',
莫代尔:是的,
打开:函数(){
$(this.load)(url);
},
关闭:功能(e){
$(this.empty();
$(this.dialog('destroy');
},
身高:350,
宽度:540,
标题:“动态对话框”
});
}))
参考:尝试使用此简单的javascript在新窗口/弹出窗口中打开aspx页面
window.open("http://www.google.com/");
window.open("~/mypage.aspx");
或
或者,如果您有一个按钮,您可以按如下方式使用它:
Button1.OnClientClick="javascript:window.open('YourPage.aspx?Param=" + ParamX.ToString() + "');";
希望这将有助于您使用Ajax模式弹出窗口。如果您想以jQuery模型的形式打开此对话框,请参阅文章 否则,如果要在模式对话框中打开此页面,可以使用以下代码打开它。此示例使用javascript的window.showModalDialog方法。有关如何使用的详细信息,请参考
函数fnRandom(iModifier){
返回parseInt(Math.random()*iModifier);
}
函数fnSetValues(){
形式变量=document.getElementById('oForm');
var iHeight=oForm.oHeight.options[oForm.oHeight.selectedIndex].text;
如果(iHeight.indexOf(“随机”)>-1){
iHeight=fnRandom(document.body.clientHeight);
}
var sFeatures=“dialogHeight:+iHeight+”px;”;
返回特征;
}
函数fnOpen(){
var sFeatures=fnSetValues();
showModalDialog(“test.aspx”,“sFeatures”)
}
是否要在单独的窗口中以“模式对话框”的形式打开此弹出窗口?IE或Chrome不再支持window.showModalDialog。而且可能很快就会在Firefox中被弃用。看见
Button1.OnClientClick="javascript:window.open('YourPage.aspx?Param=" + ParamX.ToString() + "');";
<script>
function fnRandom(iModifier) {
return parseInt(Math.random() * iModifier);
}
function fnSetValues() {
var oForm = document.getElementById('oForm');
var iHeight = oForm.oHeight.options[oForm.oHeight.selectedIndex].text;
if (iHeight.indexOf("Random") > -1) {
iHeight = fnRandom(document.body.clientHeight);
}
var sFeatures = "dialogHeight: " + iHeight + "px;";
return sFeatures;
}
function fnOpen() {
var sFeatures = fnSetValues();
window.showModalDialog("test.aspx", "", sFeatures)
}
</script>