asp.net-mvc RenderPartial onclick
问候, 我有一个 ASP.NET MVC 应用程序。我有一些与客户姓名相对应的链接。当用户单击此链接时,我想显示单击的客户端的信息以及另外一个文本区域,用户可以在其中编写有关所选客户端的一些文本(评论)。我怎样才能实现它?
编辑 我做了类似的事情:
<%=Html.ActionLink(operatorWhoAnswered.Operator.FirstName, "ShowSingleConverstationWithAnswerForm", "MyMessages", new { id = operatorWhoAnswered.Operator.ROWGUID }, new AjaxOptions() { UpdateTargetId = "ss" }) %>
我的控制器操作如下所示:
public PartialViewResult ShowSingleConverstationWithAnswerForm(string id)
{
SingleConversationWithAnswerFormViewModel vm = new SingleConversationWithAnswerFormViewModel();
PartialViewResult viewResult = new PartialViewResult();
viewResult.ViewName = "SingleConverstationWithAnswerForm";
viewResult.ViewData = new ViewDataDictionary(vm);
return viewResult;
}
但视图在新页面中打开,而不是 id="ss"
EDIT2 的 div 找到解决方案了!我不知道为什么我使用了 Html.ActionLink。 Ajax.ActionLink 工作正常!
Greetings,
I have an asp.net mvc application. I have some links that corresponds to clients names. When user clicks on this link I would like to show an information of clicked client and additionally a textarea where user shall be able to write some text (comment) about selected client. How can I achieve it?
EDIT
I've made something like:
<%=Html.ActionLink(operatorWhoAnswered.Operator.FirstName, "ShowSingleConverstationWithAnswerForm", "MyMessages", new { id = operatorWhoAnswered.Operator.ROWGUID }, new AjaxOptions() { UpdateTargetId = "ss" }) %>
and my controller action looks as follows:
public PartialViewResult ShowSingleConverstationWithAnswerForm(string id)
{
SingleConversationWithAnswerFormViewModel vm = new SingleConversationWithAnswerFormViewModel();
PartialViewResult viewResult = new PartialViewResult();
viewResult.ViewName = "SingleConverstationWithAnswerForm";
viewResult.ViewData = new ViewDataDictionary(vm);
return viewResult;
}
but view opens in a new page, instead of div with id="ss"
EDIT2
Solution found! I don't know why I have used Html.ActionLink. Ajax.ActionLink works fine!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试这样的事情:
创建一个当用户单击时应该呈现的 div。名字就像
blabla
。然后你的链接在哪里你有类似的东西并让该操作返回你的视图
Try something like this:
Create a div that should be rendered when the user clicks. Name is something lika
blabla
. Then where your link is you have something likeAnd let that action return your view