admin管理员组文章数量:1022944
Migrating my brain from WebForms to MVC, I want to:
1) click on a button, that will 2) execute some javascript, that will 3) open a new window (or tab, whichever the browser is set for), that will show an existing view from the same solution, and 4) have that view execute some data loads
I'm stuck on 3 and 4
3) in this:
function foo(){
var wrkURL = globalURLVarFromViewOneThatPointsToViewTwo
window.open(wrkURL,"_blank")
}
how do I specify the URL of another existing view (ViewTwo) in the same solution? Is there a helper that I can call within ViewOne that will create that URL within the calling view, and load into globalURLVarFromViewOneThatPointsToViewTwo? Or, if I have to spell out the URL for ViewTwo, what does that syntax look like?
4) How do I get ViewTwo to automatically do some data operations (like find data for a FlexGrid) before or immediately on being displayed? I know how to do an Ajax call to a controller/action on document.ready; is there some other way of calling a controller/action and loading the view.bag, as the view is displayed, instead?
Migrating my brain from WebForms to MVC, I want to:
1) click on a button, that will 2) execute some javascript, that will 3) open a new window (or tab, whichever the browser is set for), that will show an existing view from the same solution, and 4) have that view execute some data loads
I'm stuck on 3 and 4
3) in this:
function foo(){
var wrkURL = globalURLVarFromViewOneThatPointsToViewTwo
window.open(wrkURL,"_blank")
}
how do I specify the URL of another existing view (ViewTwo) in the same solution? Is there a helper that I can call within ViewOne that will create that URL within the calling view, and load into globalURLVarFromViewOneThatPointsToViewTwo? Or, if I have to spell out the URL for ViewTwo, what does that syntax look like?
4) How do I get ViewTwo to automatically do some data operations (like find data for a FlexGrid) before or immediately on being displayed? I know how to do an Ajax call to a controller/action on document.ready; is there some other way of calling a controller/action and loading the view.bag, as the view is displayed, instead?
Share Improve this question edited Feb 15, 2014 at 20:41 wayfarer asked Feb 15, 2014 at 20:31 wayfarerwayfarer 7902 gold badges17 silver badges35 bronze badges2 Answers
Reset to default 2For building the Url, look at the URL helper:
@Url.Action("ActionName", "Controller", new {
someVariable= someData
})
As for #4, notice that when I'm building the URL, I'm building it with route parameters. These parameters will be passed to your controller's action and you can do what you please with them (just make sure routing is configured so you'll get the appropriate match for your intended action).
Actually action methods respond to URLs. So you need to create a URL for the action method. Make sure you return that specific view from the action.
var wrkURL = '@Url.Action("SomeAction", "SomeController")';
Migrating my brain from WebForms to MVC, I want to:
1) click on a button, that will 2) execute some javascript, that will 3) open a new window (or tab, whichever the browser is set for), that will show an existing view from the same solution, and 4) have that view execute some data loads
I'm stuck on 3 and 4
3) in this:
function foo(){
var wrkURL = globalURLVarFromViewOneThatPointsToViewTwo
window.open(wrkURL,"_blank")
}
how do I specify the URL of another existing view (ViewTwo) in the same solution? Is there a helper that I can call within ViewOne that will create that URL within the calling view, and load into globalURLVarFromViewOneThatPointsToViewTwo? Or, if I have to spell out the URL for ViewTwo, what does that syntax look like?
4) How do I get ViewTwo to automatically do some data operations (like find data for a FlexGrid) before or immediately on being displayed? I know how to do an Ajax call to a controller/action on document.ready; is there some other way of calling a controller/action and loading the view.bag, as the view is displayed, instead?
Migrating my brain from WebForms to MVC, I want to:
1) click on a button, that will 2) execute some javascript, that will 3) open a new window (or tab, whichever the browser is set for), that will show an existing view from the same solution, and 4) have that view execute some data loads
I'm stuck on 3 and 4
3) in this:
function foo(){
var wrkURL = globalURLVarFromViewOneThatPointsToViewTwo
window.open(wrkURL,"_blank")
}
how do I specify the URL of another existing view (ViewTwo) in the same solution? Is there a helper that I can call within ViewOne that will create that URL within the calling view, and load into globalURLVarFromViewOneThatPointsToViewTwo? Or, if I have to spell out the URL for ViewTwo, what does that syntax look like?
4) How do I get ViewTwo to automatically do some data operations (like find data for a FlexGrid) before or immediately on being displayed? I know how to do an Ajax call to a controller/action on document.ready; is there some other way of calling a controller/action and loading the view.bag, as the view is displayed, instead?
Share Improve this question edited Feb 15, 2014 at 20:41 wayfarer asked Feb 15, 2014 at 20:31 wayfarerwayfarer 7902 gold badges17 silver badges35 bronze badges2 Answers
Reset to default 2For building the Url, look at the URL helper:
@Url.Action("ActionName", "Controller", new {
someVariable= someData
})
As for #4, notice that when I'm building the URL, I'm building it with route parameters. These parameters will be passed to your controller's action and you can do what you please with them (just make sure routing is configured so you'll get the appropriate match for your intended action).
Actually action methods respond to URLs. So you need to create a URL for the action method. Make sure you return that specific view from the action.
var wrkURL = '@Url.Action("SomeAction", "SomeController")';
本文标签: jqueryaspnet mvc open another view in javascriptStack Overflow
版权声明:本文标题:jquery - asp.net mvc open another view in javascript - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745498543a2153281.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论