如何将页面内容加载到另一个页面的弹出窗口?
这是带有弹出窗口的主页的HTML代码,
<div class="box">
<a class="button" href="#divOne">
<img src="~/images/usericon.png" alt="user" width="30" height="30" />
</a>
</div>
<div class="overlay" id="divOne">
<div class="wrapper">
<div id="container">
<div class="btn" id="btn-1" data-showbutton="1">Login</div>
<div data-button="1">
<a href="#" class="close" onclick="clearData()">×</a>
<div class="content">
<div class="container text-active">
@* load page content here*@
<form id="login">
<label>Username</label>
<input type="text" placeholder="Username" />
<label>Password</label>
<input type="text" placeholder="Password" />
</form>
</div>
</div>
<button>Login</button>
</div>
<div class="btn" id="btn-2" data-showbutton="2">Register</div>
<div id="is-hidden" data-button="2">
<a href="#" class="close" onclick="clearData()">×</a>
<div class="content">
<div class="container">
<div class="container text-active">
@* load page content here*@
<form id="register">
<label>Username</label>
<input type="text" placeholder="Username" />
<label>Password</label>
<input type="text" placeholder="Password" />
<label>Confirm Password</label>
<input type="text" placeholder="Confirm Password" />
</form>
</div>
</div>
</div>
<button>Register</button>
</div>
</div>
</div>
</div>
这是我想
@model Store.Models.CustomerModel
@{
ViewData["Title"] = "Register";
}
@* this part is what I need*@
<div class="row">
<div class="col-md-4">
<form asp-action="Register">
<div asp-validation-summary="ModelOnly" class="text-danger"></div>
<div class="form-group">
<label asp-for="CustomerEmail" class="control-label"></label>
<input asp-for="CustomerEmail" class="form-control" />
<span asp-validation-for="CustomerEmail" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="CustomerPassword" class="control-label"></label>
<input asp-for="CustomerPassword" class="form-control" />
<span asp-validation-for="CustomerPassword" class="text-danger"></span>
</div>
<div class="form-group">
<input type="submit" value="Create" class="btn btn-primary" />
</div>
</form>
</div>
</div>
@* this part is what I need*@
在我尝试过的弹出窗口中显示的页面内容,包括模型并粘贴代码,但我想在主之间进行分离页面和登录表单。
这就是外观,如果需要
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将重复的代码移动到 partial ,,,
@model /code>将设置为
customerModel
:在主页中,您需要添加
customermodel
属性,例如,然后将其传递给部分,您可以使用部分标记
助手再次部分,但是您无需通过属性来指定部分中的模型,因为默认情况下将传递主机页面的模型:
Move the duplicated code to a partial, with its
@model
set toCustomerModel
:In the main page, you need to add a
CustomerModel
property e.g.and then pass it to the partial, which you can do using a partial tag helper:
In the Customer page, you include the partial again, but you don't need to specify a model via the
for
attribute in the partial because the host page's model will be passed by default: