如果我点击执行按钮我将我的动作重定向到视图(GetSection),在这个页面中,部分视图(CoverPage)应该自动呈现而没有任何事件,它只有navbar和CoverPage也是导航栏的一部分,所有的navbar值都来了从数据库中,我试过" @ Html.RenderPartial(" CoverPage")"语法,但它不适合我,这是我的查看页面
<table style="width:auto">
@foreach (Test_Section p in Model)
{
<tr>
<td>
<div id="ajaxnav" class="navbar-left">
<ul class="nav nav-pills nav-stacked">
<li class="navigationLink">
@Ajax.ActionLink(p.SectionName, p.Title, new { id = p.StdSectionId },
new AjaxOptions
{
UpdateTargetId = "getHtml",
InsertionMode = InsertionMode.Replace,
HttpMethod = "GET"
}, new { style = "color:black" , @class = "navigationLink" })
</li>
</ul>
</div>
</td>
</tr>
}
<div id="getHtml" class="divhtml"></div>
</table>
,控制器是
public ActionResult GetSections()
{
Test_Section[] section = context.Test_Section.ToArray();
return PartialView(section);
}
所以请帮助我。
答案 0 :(得分:1)
从您的评论中,您似乎想加载页面加载时第一个链接的点击事件的响应。
您可以使用jquery public class AccountController : Controller
{
[HttpGet]
public ActionResult Login(string returnUrl)
{
return View(new LoginViewModel { ReturnUrl = returnUrl });
}
[HttpPost]
public async Task<ActionResult> Login(LoginViewModel vm)
{
if (!ModelState.IsValid)
{
return View(vm);
}
// Call IdentityServer here with credentials
TokenResponse token = await GetToken(vm.UserName, vm.Password);
// Validate token and do the Owin Authentication SignIn
// Redirect to 'ReturnUrl'
await SignInAsync(token);
return new RedirectResult(vm.ReturnUrl);
}
[Authorize]
public ActionResult SocialLogin(string returnUrl)
{
return new RedirectResult(returnUrl);
}
// Some helpers omitted
}
方法触发链接点击文档就绪事件。
trigger