mvc4控制可恢复性的局部视图 [英] Partial View in mvc4 Control Resuability

查看:90
本文介绍了mvc4控制可恢复性的局部视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下午好,



我有2页,1。登录,2。注册。



在注册页面我有4个控件用户名,密码,确认密码和电子邮件。



在登录页面中,我在登录页面中有用户名和密码控件。



如果我将register.cshtml页面放在共享中,当我调用登录页面时......我的想法通过隐藏确认密码和电子邮件来控制登录页面中只能通过隐藏确认密码和电子邮件从register.cshtml调用的用户名和密码。



你可以建议我,我能做到这一点吗,我刚开始接受MVC培训。

Good Afternoon,

I have 2 Pages , 1.login ,2. Register.

In Register page i have 4 controls Username,Password,confirm Password,and Email.

In Login page i have Username and Password control in login page .

If i put register.cshtml page in shared ,when i call login page ...my idea to have controls only username and password in login page that to be called from register.cshtml by hiding confirm password and email.

can u suggest me haw can i do this ,i just started my training in MVC .

推荐答案

嗨Karthik,



我还没试过这个,但这将作为你的参考。

尝试这个和lemme知道

Hi Karthik,

I have'nt tried this, but this will be used as a reference to you.
try this and lemme know
@using (Html.BeginForm()){
<p>
<label for="FirstName">First Name:</label>
@Html.TextBox("FirstName") 
@Html.ValidationMessage("FirstName", "*") 
</p>
<p>
<label for="Password">Password:</label>
@Html.TextBox("Password")
@Html.ValidationMessage("LastName", "*") 
</p>
<p>
@If ( IsRegister == true ) //IsRegister variable should be retrieved from controller to identify the call for Login/Register
{
//If its true then display the remaining controls
<label for="CnfrmPassword"> Confirm Password:</label>
@Html.TextBox("CnfrmPassword") 
@Html.ValidationMessage("CnfrmPassword", "*") 
</p>
<p>
<label for="Email">Email:</label>
@Html.TextBox("Email") 
@Html.ValidationMessage("Email", "*") 
</p>
<p>
}
}</p>



希望这对你有所帮助。



问候,

RK


Hope this helps you a bit.

Regards,
RK


这篇关于mvc4控制可恢复性的局部视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆