Click here to Skip to main content
15,897,185 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How Can I access to element of one controller in the partial view of another Controller?
Posted

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()
{

}))
{%>




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'});"
 
Share this answer
 
v2
hi,

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.

 
Share this answer
 
v2
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.
 
Share this answer
 
Comments
shaghyegh 24-Aug-10 2:09am    
you are right,i worked with asp.net mvc:) I'm Begener in Ajax I want show JUST some text of One contoller in the partial view of anOther controller I want use Ajax but when I run my project and click in the link, it makes copy of that page for me while I just want add a text that I wrote with out refresh page!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900