如何在弹出窗口中打开aspx网页

时间:2013-07-10 22:31:50

标签: asp.net vb.net visual-studio-2008 popup asplinkbutton

我正在尝试编写一个代码,在另一个.ASPX网页(使用VB)上单击LinkBut​​ton后打开.aspx(弹出窗口的形状)

Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs)      Handles LinkButton1.Click

    'What code?

End Sub

不知道怎么做,我找不到弹出控件或类似的东西。

2 个答案:

答案 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" });
    }

请参阅:open a web page in modal popup in asp.net using jquery