我正在尝试编写一个代码,在另一个.ASPX网页(使用VB)上单击LinkButton后打开.aspx(弹出窗口的形状)
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
'What code?
End Sub
不知道怎么做,我找不到弹出控件或类似的东西。
答案 0 :(得分:7)
您可以使用ClientScript.RegisterStartupScript
在C#中
protected void Button1_Click(object sender, EventArgs e)
{
string queryString = "test.aspx" ;
string newWin ="window.open('" + queryString + "');";
ClientScript.RegisterStartupScript(this.GetType(), "pop", newWin, true);
}
在VB中
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim queryString As String = "test.aspx"
Dim newWin As String = "window.open('" & queryString & "');"
ClientScript.RegisterStartupScript(Me.GetType(), "pop", newWin, True)
End Sub
答案 1 :(得分:1)
使用jQuery很容易在ASP.NET中的模态弹出窗口中打开网页或Web表单:
$(function () {
modalPosition();
$(window).resize(function () {
modalPosition();
});
$('.openModal').click(function (e) {
$('.modal, .modal-backdrop').fadeIn('fast');
e.preventDefault();
});
$('.close-modal').click(function (e) {
$('.modal, .modal-backdrop').fadeOut('fast');
});
});
function modalPosition() {
var width = $('.modal').width();
var pageWidth = $(window).width();
var x = (pageWidth / 2) - (width / 2);
$('.modal').css({ left: x + "px" });
}