我该如何进入 [英] How Can I access
问题描述
如何在另一个控制器的局部视图中访问一个控制器的元素?
How Can I access to element of one controller in the partial view of another Controller?
推荐答案
只需在视图中创建一个div即可显示文本.然后使用ajax回发显示文本... kk ..
给你一个例子... kk ..希望这可以帮到你..
<%使用(Ajax.BeginForm(new AjaxOptions()
{
}))
{%>
just create a div in your view to display the text..then display the text using ajax postback...kk..
am giving you 1 example...kk..Hope this may help you..
<% using (Ajax.BeginForm(new AjaxOptions()
{
}))
{%>
并且如果您在该div中具有按钮或任何html控件,只需将此代码粘贴到onclick事件中
onclick ="Sys.Mvc.AsyncHyperlink.handleClick(this,new Sys.UI.DomEvent(event),{insertionMode:Sys.Mvc.InsertionMode.replace,httpMethod:``POST'',updateTargetId:``DivId''} );"
and if you have button or any html control in that div just paste this code in the onclick event
onclick="Sys.Mvc.AsyncHyperlink.handleClick(this, new Sys.UI.DomEvent(event), {insertionMode: Sys.Mvc.InsertionMode.replace, httpMethod: ''POST'', updateTargetId: ''DivId''});"
hi,
首先,请提供您实际想要的描述.
请详细说明您的方案.
根据克里斯汀·格劳斯(Christain Graus)的说法,您的需求无法实现
为什么,因为,我们没有在Controller中获得视图"的控件".
要获取控件"值,请使用类型化结构"或"FormCollection",当我们使用类型化结构时,可以通过将实体值传递给每个控制器来访问任何控制器中的值.
first upon please give the description for , what actually you want.
Please specify your scenario in detail.
As per Christain Graus, your need is not possible
why because, we dont get the "controls" of a "view" in Controller.
For getting the "controls" Value , use "typed structure" or "FormCollection", when we are using a typed structure you can access the value in any controller , by passing the entity value to each controller.
注意:-控制器不是网页.它充当,控制视图"和模型" .我们可以在一个控制器中创建多个视图" .
Note :- Controller is not a web page. It act as , controlling "View" and "Model". We can create more than one "View" in a single controller.
您正在使用ASP.NET,而不是ASP,并且您的问题与AJAX无关. MVC中的控制器基本上是一个内存中的网页,在这种情况下,我希望您不能.除页面生命周期的上下文外,您的页面不存在.您需要修复设计,而无需这样做.
you''re using ASP.NET, not ASP, and your question has NOTHING to do with AJAX. A controller in MVC is basically a web page, from memory, in which case, I expect you cannot. Your pages do not exist, except in the context of a page lifecycle. You need to fix your design so you don''t need to do this.
这篇关于我该如何进入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!