2014-01-16 45 views
0

在我的表中,我從客戶端窗口中選擇標籤的文本,因爲它有太多的選項。如何從客戶端(彈出)窗口中選擇標籤值?

主頁:

<asp:Label ID="lblText" runat="server">Select Options/asp:Label> 
<img onclick="SelectOptions();" src="images/select.png" 
    title="Select Options" style="cursor: pointer" /> 
//JavaScript: 
function SelectOptions() { 
    var popup; 
    popup = window.open("popOptions.htm", "width=530,height=330"); 
    popup.focus(); 
} 

客戶端窗口(彈出窗口)

window.opener.document.getElementById("lblText").innerHTML = "XYZ"; 

選擇選項(在提交按鈕單擊),當我嘗試選擇lblText文本後,它即使在屏幕上顯示「XYZ」,也會返回「選擇選項」而不是「XYZ」。這意味着lblText.Text返回「選擇選項」而不是「XYZ」。

所以我的問題是我怎麼能得到「XYZ」,而不是它的默認值?

回答

0
  1. 創建首戰功能(主)頁:

    function SetTextToLabel(newText) { 
        document.getElementById("lblText").innerHTML = newText; 
    }; 
    
  2. 而不是

    window.opener.document.getElementById("lblText").innerHTML = "XYZ"; 
    

    調用新功能

    window.opener.SetTextToLabel("YourNewText"); 
    
+0

我試過這個,但它仍然給出了默認值。 – hims056

+0

您爲「選擇」標籤設置了什麼事件?之後你如何試圖獲得HTML? –

+0

對不起,我沒有得到你。 – hims056

相關問題