2011-07-20 10 views
0

親アプリケーションから開いた子ブラウザウィンドウ(aspx)があります。子ウィンドウにはいくつかのコントロールとテキストボックスがあります。ユーザーが終了すると、S /彼はボタンをクリックすると、そのように次のコードは、子ウィンドウから値を取り、親を取り込みますASP.NETとJavascript:あるウィンドウから別のウィンドウに値を設定する

window.opener.document.form1.InputContainer$LetterInput$txtReasons.value = txtVal; 

これは私が親ページに持っているテキストボックスのための素晴らしい作品。しかし今、私はリストボックスに値を設定する必要があり、多くの運がないです。私はこれらの2つの方法を試したが役に立たなかった。

o.text = txtVal; 
o.value = "1"; 
window.opener.document.form1.InputContainer$LetterInput$lstReasons.add(o); 

window.opener.document.form1.InputContainer$LetterInput$lstReasons.add("Text", "Value"); 

"htmlfile:このようなインターフェースはサポートされていない"というメッセージが表示されます。

誰もが考えている?

おかげで、

ジェイソン

答えて

0

大丈夫、少し手直しを取ったが、解決策を見つけました!

まず第一に、このような親のaspx内の関数を作成します。

function NewOption(newVal) 
{ 
//alert("The entry is: " + newVal); 
var sel = document.getElementById("<%= MyListbox.clientID %>"); 
sel.options[sel.options.length]=new Option(newVal, newVal, true, true);  
} 

次に、このように子ページからその関数を呼び出す:

function SendValues() 
{ 
var txtVal = document.form1.txtReasons.value; 
var sel = window.opener.NewOption(txtVal); 
} 

キンクや二つは(まだあります値だけでなくテキストも渡しますが、余分なパラメータを追加することで簡単に修正できます...

うまくいけば、他の誰かがそれを使うことができたらうれしいです!

0
var newOption = document.createElement('option'); 
newOption.value = textbox.value; // The value that this option will have 
newOption.innerHTML = textbox.value; // The displayed text inside of the <option> tags 

// Finally, add the new option to the listbox 
window.opener.document.form1.InputContainer$LetterInput$lstReasons.appendChild(newOption); 
+0

「このようなインターフェイスはサポートされていません」ということは、まだその上に運がありません。しかし、真剣に、投稿していただきありがとうございます! –

+0

window.opener.document.getElementById( 'InputContainer_LetterInput_lstReasons').appendChild ....... –

関連する問題