我有一个主页面,里面有一个模态。我想使用模式以允许客户向管理员发送电子邮件。问题是,由于我插入了模态,我得到一个&#34;页面有一个或多个<asp:Content>
控件,与主页中的<asp:ContentPlaceHolder>
控件不对应&#34;使用此母版页的所有页面上的错误。当我评论模态代码时,一切都还可以。
我该怎么办?
这是我的代码:
<%@ Master Language="C#" AutoEventWireup="true" CodeBehind="MasterPage.Master.cs"
Inherits="KAFA_SAJT.MasterPage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title id="titl" runat="server"></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href="Style/Stilovi.css" rel="stylesheet" type="text/css" />
<script src="jquery-2.2.0.min.js" type="text/javascript"></script>
<script src="../jquery-2.2.0.min.js" type="text/javascript"></script>
<script src="jquery-ui.js" type="text/javascript"></script>
<script src="../jquery-ui.js" type="text/javascript"></script>
<link href="jquery-ui.css" rel="stylesheet" type="text/css" />
<link href="Style/bootstrap.min.css" rel="stylesheet" type="text/css" />
<script src="bootstrap.min.js" type="text/javascript"></script>
</head>
<body>
<form id="form1" runat="server">
<div id="banner">
<div id="login" style="text-align: right; padding-right: 15px; padding-top: 9px;">
<asp:Label ID="lblLogin" runat="server" ForeColor="White"></asp:Label>
<br />
<asp:LinkButton ID="lbLogin" ForeColor="White" Style="text-decoration: none;" runat="server"
OnClick="lbLogin_Click" CausesValidation="False">
LinkButton</asp:LinkButton>
</div>
</div>
<div class="navbar navbar-inverse navbar-static-top" style="margin: 0">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".collapsable">
<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar">
</span>
</button>
<a class="navbar-brand" href="#">Coffe Site</a>
</div>
<div class="collapse navbar-collapse collapsable">
<ul class="nav navbar-nav navbar-right">
<li><a href="~/Home.aspx" runat="server">Home</a></li>
<li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown">Pregled
<b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="~/Kafa.aspx" runat="server">Kafe</a></li>
<li><a href="#">Pregled Prodavnice</a></li>
<li><a href="#">Brendovi Kafe</a></li>
</ul>
</li>
<li><a href="~/Kupovina.aspx" runat="server">Kupovina</a></li>
<li><a href="#">O nama</a></li>
<button type="button" class="btn btn-link" data-toggle="modal" data-target="#modalContact"
style="padding: 13px; text-decoration: none">
Kontakt</button>
<li><a id="linkPromenaLozinke" href="~/Nalozi/ChangePassword.aspx" runat="server">Promena
lozinke</a></li>
<li class="dropdown"><a href="#" id="linkManagement" class="dropdown-toggle" data-toggle="dropdown"
runat="server">Management <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a id="A1" href="~/Management.aspx" runat="server">Kafe</a></li>
<li><a id="A2" href="~/Nalozi/LockedAccounts.aspx" runat="server">Zakljucanih</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div>
<div id="modalContact" class="modal fade" role="dialog" runat="server">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×</button>
<h4 class="modal-title">
Kontaktirajte nas</h4>
</div>
<div class="modal-body">
<form class="form-horizontal" role="form" action="#">
<div class="form-group">
<label class="control-label col-sm-2" for="txtName">
Name:</label>
<div class="col-sm-10">
<input type="text" runat="server" class="form-control" id="txtName" placeholder="Enter Name" />
<asp:RequiredFieldValidator ID="txtNameRequiredFieldValidator" runat="server" ErrorMessage="Name Required"
Display="Dynamic" Text="*" ControlToValidate="txtName" ForeColor="Red" ValidationGroup="Kontakt"></asp:RequiredFieldValidator>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Email">
Email:</label>
<div class="col-sm-10">
<input type="text" runat="server" class="form-control" id="txtEmail" placeholder="Enter Email" />
<asp:RequiredFieldValidator ForeColor="Red" ID="emailRequiredFieldValidator" runat="server"
ErrorMessage="Email Required" Display="Dynamic" Text="*" ControlToValidate="txtEmail"
ValidationGroup="Kontakt"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ForeColor="Red" ID="emailRegularExpressionValidator"
runat="server" ErrorMessage="Email not in proper format" Display="Dynamic" Text="*"
ControlToValidate="txtEmail" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"
ValidationGroup="Kontakt"></asp:RegularExpressionValidator>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Subject">
Subject:</label>
<div class="col-sm-10">
<input type="text" runat="server" class="form-control" id="txtSubject" placeholder="Enter Subject" />
<asp:RequiredFieldValidator ForeColor="Red" ID="subjectRequiredFieldValidator" runat="server"
ErrorMessage="Subject Required" Display="Dynamic" Text="*" ControlToValidate="txtSubject"
ValidationGroup="Kontakt"></asp:RequiredFieldValidator>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-2" for="Comments">
Comments:</label>
<div class="col-sm-10">
<textarea runat="server" class="form-control" id="txtComments" placeholder="Enter Comment"
rows="4" cols="20" name="S1" />
<asp:RequiredFieldValidator ForeColor="Red" ID="commentsRequiredFieldValidator" runat="server"
ErrorMessage="Comments Required" Display="Dynamic" Text="*" ControlToValidate="txtComments"
ValidationGroup="Kontakt"></asp:RequiredFieldValidator>
</div>
</div>
</form>
</div>
<div class="modal-footer">
<asp:Button ID="btnUpit" runat="server" ValidationGroup="Kontakt" OnClick="btnUpit_Click"
Text="Pošalji upit" />
<asp:ValidationSummary ID="kontaktValidationSummary" HeaderText="Please fix the following errors"
ForeColor="Red" runat="server" ValidationGroup="Kontakt" Style="text-align: left" />
<asp:Label ID="tnxLabel" runat="server"></asp:Label>
</div>
</div>
</div>
</div>
<div id="sadrzaj">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server"></asp:ContentPlaceHolder>
</div>
</form>
</body>
</html>
答案 0 :(得分:1)
此行为的原因是您的模式标记中包含表单标记。所以你的标记方案是:
<body>
<form>
<div modal>
<form>
</form>
</div modal>
</form>
</body>
在ASP.NET中不允许这样做,除非你实现了一些脏黑客,否则你必须在ASP.NET页面上只有一个表单。所以你的标记看起来应该是
<body>
<form>
<div modal>
<!-- no form tag here -->
</div modal>
</form>
</body>