如何通过MVC中的jquery将值从弹出窗口传递到父窗口 [英] How to pass values from pop up window to parent window through jquery in MVC
问题描述
我的视图页面上有三个按钮,分别是"Button1" ,"Button2" 和"Button3" ,我有三个对应于每个按钮的TextBox,分别表示"TextBox1 ","TextBox2" 和& "TextBox3" .单击任何一个按钮时,我都可以打开一个弹出窗口.现在,我想将某些值从POP向上视图传递到父视图,并将该值传递给与被单击的按钮相关联的TextBox.我该怎么办?
i have three buttons in my view page says "Button1", "Button2" & "Button3" and i have three TextBoxes corresponds to each button says "TextBox1","TextBox2" & "TextBox3" . When clicking on any one button i m able to open one pop up window. Now i want to pass some values to the parent view from POP up view and pass that value to the TextBox associate with the button which is being clicked. How can i do this?
修改
<input type="button" value="Buuton1" id="Button1" style="width:100px;font-family:Verdana; font-size:9px; onclick="window.open( '<%= Url.Action( "Popup", "Home" ) %>');" />
<input type="button" value="Button2" id="Button2" style="width:100px;font-family:Verdana; font-size:9px;" onclick="window.open( '<%= Url.Action( "Popup", "Home" ) %>');" />
<input type="button" value="Button3" id="Button3" style="width:100px;font-family:Verdana; font-size:9px;" onclick="window.open( '<%= Url.Action( "Popup", "Home" ) %>');" />
推荐答案
为文本框提供一个ID(例如textBox1
),然后尝试此操作.这是一个简单的JavaScript.
您不需要jQuery.
Give an id to the textboxes (for example textBox1
), then try this..it's a simple JavaScript.
You don't need jQuery for this.
window.opener.document["nameForm"].getElementById("textBox1 ").value = "your some values will go here"
这篇关于如何通过MVC中的jquery将值从弹出窗口传递到父窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!