使用javascript打开一个弹出窗口

时间:2010-03-25 04:21:00

标签: c# javascript parameters popup popupwindow

我想在我的c#.net应用中使用javascript打开一个弹出窗口。这是我的webform

中body标签中的代码
<script language=javascript>
    function openWindow(strEmail)
    {        
    window.open('CheckEmail.aspx?email=' + strEmail + , 'Check Email','left=100,top=100,toolbar=no,scrollbars=yes,width=680,height=350');
    return false;
    }
</script>

这是我在Page_Load部分的代码

this.btnCheck.Attributes.Add("onclick", "return openWindow(" + txtEmail.Text + ");");

现在我正在尝试从我的文本框“txtEmail”传递字符串,所以在我的弹出窗口中我可以得到request.querystring但我不太确定语法是什么。

2 个答案:

答案 0 :(得分:1)

不需要上一个+

window.open('CheckEmail.aspx?email=' + strEmail,'Check Email','left=100,top=100,toolbar=no,scrollbars=yes,width=680,height=350');

在CheckEmail.aspx页面中,您可以将查询字符串作为

Request.QueryString["email"]

在textEmail.Text

周围的函数内部的CS侧使用'
this.btnCheck.Attributes.Add("onclick", "return openWindow('" + txtEmail.Text + "');");

答案 1 :(得分:0)

如果txtEmail控件可见,为什么不在客户端代码中收到电子邮件。

function openWindow()
{  
   var email = document.getElementById('<%=txtEmail.ClientID%>').value;
   window.open('CheckEmail.aspx?email=' + email + , 'Check Email','left=100,top=100,toolbar=no,scrollbars=yes,width=680,height=350');
   return false;
}
相关问题