0

I have a link button inside UpdatePanel in a div popup. On Button_Click, I wish to open a new window through javascript. I tried both ScriptManager.RegisterStartupScript as well as ScriptManager.RegisterClientScriptBlock, but Window doesn't open.

    <asp:UpdatePanel ID="UpdatePanel2" runat="server">

                                            <ContentTemplate> 
                <form class="message-form" action="#">
                    <fieldset>
    <asp:LinkButton ID="LinkButton1" runat="server" class="btn-facebook" Text="facebook" OnClick="LinkButton1_Click"></asp:LinkBu

tton>
                    <label for="TextBox1">Or send a message on Blissdate here:</label>
                <div class="textarea">
                    <asp:TextBox ID="TextBox1" runat="server" TextMode="MultiLine" Rows="10" Columns="30"></asp:TextBox><asp:Label ID="lbl" runat="server" />
                </div>
                <div class="btn-holder">
                    <asp:LinkButton ID="LinkButton2" runat="server" class="btn-send" Text="send" OnClick="LinkButton2_Click"></asp:LinkButton>
                </div>

            </fieldset>
        </form>

protected void LinkButton1_Click(object sender, EventArgs e)
    {
           DataRow[] row1 = ds.Tables[0].Select("FB_Id='" + HiddenField3.Value + "'");
           string url = row1[0].ItemArray[3].ToString();
           lbl.Text = url;
           //ScriptManager.RegisterClientScriptBlock(this, GetType(), "newPage", "window.open('" + url +');", true);
           ScriptManager.RegisterClientScriptBlock(this, GetType(), "newpage", "open('" + url + "');", true);
    }





<script type="text/javascript">
    function open(url) {
        var w = window.open(url, '', 'width=1000,height=600,toolbar=0,status=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1');

        w.focus();

    }
</script>

Please tell me if something is wrong with the code..

4

2 に答える 2

6

関数の名前を別の名前に変更openします。ブラウザでjavascriptコンソールを起動すると、への再帰呼び出しが多数表示されますopen。私はJavaScriptの専門家ではありませんが、スタックオーバーフローの例外が発生していると思います。

<script type="text/javascript">
function customOpen(url) {
    var w = window.open(url, '', 'width=1000,height=600,toolbar=0,status=0,location=0,menubar=0,directories=0,resizable=1,scrollbars=1');
    w.focus();

 }
</script>

次に、登録を変更します。

ScriptManager.RegisterClientScriptBlock(this, GetType(), "newpage", "customOpen('" + url + "');", true);
于 2012-04-05T06:21:50.600 に答える
0

Check your browser popup blocker is enabled. Please disabled that it will work....

于 2012-04-05T06:03:37.727 に答える