2010-03-25 150 views
0

我想在我的c#.net應用程序中使用javascript打開一個彈出窗口。這是我的網頁表單body標籤的代碼使用javascript打開彈出窗口

<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,但是Im有點不確定語法。

回答

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; 
} 
+0

非常感謝John – newName 2010-03-25 07:11:27

1

無需最後+

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

和CheckEmail.aspx頁面,您可以繞過textEmail函數內部的查詢字符串作爲

Request.QueryString["email"] 

使用'在CS側的.Text

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

感謝拉胡爾,在彈出的窗口管理工作,但該地址的彈出窗口顯示我的電子郵件爲未定義「CheckEmail.aspx?電子郵件=未定義」 – newName 2010-03-25 04:42:01

+0

你可以調用像'的openWindow功能(「我@ there.com');'用電子郵件地址引用引號,或者包含電子郵件地址且不包含空的變量 – 2010-03-25 04:47:53

+0

其實我的功能是取用戶在文本框中輸入的任何內容,在這種情況下,這將是電子郵件地址和檢查它針對數據庫,並且此函數將在我的新彈出窗口的Page_Load中運行,因此它可以通知用戶是否存在電子郵件。因此它要抓取文本字符串作爲查詢字符串傳遞給我的新窗口,並在我的新窗口中檢查我的檢查 – newName 2010-03-25 04:55:13

相關問題