简体   繁体   中英

how to pass parameter as model to a new view via javascript function window.open?

I want to create a popup window when selecting a row in the grid panel. I used javascipt function to create a new window but i can't figure out how to send the selected element to this window to be showed with details.

the main view has as model : @model IEnumerable<Models.warning>

the child view (the popup window) has as model : @model warning i want to use window.open("/Examples/WarningDetail", "_blank", "left=100,top=100,width=400,height=300,toolbar=1,resizable=0");

You can use window.opener to access the parent window to get the model in the child window. Anyway this will not work in cross domian request ie if you parent and child windows are from different domains.

One of the problem in passing model through the query string would be the size of the model. There are constraint in the size of the query string.

Resource:

http://www.w3schools.com/jsref/prop_win_opener.asp

https://developer.mozilla.org/en-US/docs/Web/API/Window.opener

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM