Asp.net mvc 4 在jQuery Mobile中为POST链接格式化列表项
我有一个关于jquerymobile格式化的问题,以及如何让Asp.net mvc 4 在jQuery Mobile中为POST链接格式化列表项,asp.net-mvc-4,jquery-mobile,Asp.net Mvc 4,Jquery Mobile,我有一个关于jquerymobile格式化的问题,以及如何让在列表视图中正确格式化。VisualStudio中移动应用程序的MVC4默认模板有一个注销链接,该链接使用GET调用注销。以下是标记: <ul data-role="listview" data-inset="true"> <li>@Html.ActionLink("Change password", "ChangePassword&q
在列表视图中正确格式化。VisualStudio中移动应用程序的MVC4默认模板有一个注销链接,该链接使用GET调用注销。以下是标记:
<ul data-role="listview" data-inset="true">
<li>@Html.ActionLink("Change password", "ChangePassword")</li>
<li>@Html.ActionLink("Log off", "LogOff")</li>
</ul>
使用jQuery Mobile时,情况如下所示:
<ul data-role="listview" data-inset="true">
<li>@Html.ActionLink("Change password", "ChangePassword")</li>
<li>@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
{@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>}
</li>
</ul>
相反,互联网应用程序的MVC 4默认模板使用POST方法进行相同的注销:
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id =
"logoutForm" })) {@Html.AntiForgeryToken()
<a ref="javascript:document.getElementById('logoutForm').submit()">Log off</a>}
@使用(Html.BeginForm(“注销”、“帐户”、FormMethod.Post、新{id=
“logoutForm”}){@Html.AntiForgeryToken()
)。我可以让链接正常工作,但我遇到的问题是让按钮看起来与使用get方法时一样
我的标记如下所示:
<ul data-role="listview" data-inset="true">
<li>@Html.ActionLink("Change password", "ChangePassword")</li>
<li>@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
{@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>}
</li>
</ul>
- @ActionLink(“更改密码”、“更改密码”)
- @使用(Html.BeginForm(“注销”、“帐户”、FormMethod.Post、新{id=“logoutForm”}))
{@Html.AntiForgeryToken()
}
但结果是这样的:
<ul data-role="listview" data-inset="true">
<li>@Html.ActionLink("Change password", "ChangePassword")</li>
<li>@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
{@Html.AntiForgeryToken()
<a href="javascript:document.getElementById('logoutForm').submit()">Log off</a>}
</li>
</ul>
我尝试将
标记放在
标记的周围,但效果并不好:
有人能解释一下为什么这个标签的格式不同于上面的标签,以及我如何让它看起来像这篇文章顶部的标签吗?除非你想在列表项中创建自己的自定义CSS,否则不要将实际的
放在里面,因为表单有自己的默认CSS。Instead将表单放在列表项之外的某个位置,并将按钮本身放在列表项内
<ul data-role="listview" data-inset="true">
<li>@Html.ActionLink("Change password", "ChangePassword")</li>
<li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li>
</ul>
@using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm" }))
{
@Html.AntiForgeryToken()
}
- @ActionLink(“更改密码”、“更改密码”)
@使用(Html.BeginForm(“注销”、“帐户”、FormMethod.Post、新{id=“logoutForm”}))
{
@Html.AntiForgeryToken()
}
尝试将表单放在div中!成功了!谢谢,这正是我想要的洞察力。很高兴我没有创建自定义CSS。哇……太简单了。谢谢!嘿,这是你的网站吗?