我有两个这样的按钮:
<button class="platinum_inquiry" type="submit" data-toggle="modal" data-target="#clientContactModal">Send Inquiry</button>
<button class="gold_inquiry" type="submit" data-toggle="modal" data-target="#clientContactModal">Send Inquiry</button>
并且我在同一个cshtml类中有一个模式:
<div class="modal fade" id="clientContactModal" tabindex="-1" role="dialog" style="padding-top:50px !important;">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">We need some more information</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<form>
<div class="modal-body">
@Html.ValidationSummary(true,"",new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.DateReservation,htmlAttributes: new { @class = "control-label" })
<div class="col-md-10">
@Html.EditorFor(model => model.DateReservation,new { htmlAttributes = new { @class = "form-control",@readonly = "readonly" } })
@Html.ValidationmessageFor(model => model.DateReservation,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ApartmentName,htmlAttributes: new { @class = "control-label" })
<div class="col-md-10">
@Html.EditorFor(model => model.ApartmentName,@readonly = "readonly" } })
@Html.ValidationmessageFor(model => model.ApartmentName,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Guestsnumber,htmlAttributes: new { @class = "control-label" })
<div class="col-md-10">
@Html.TextBoxFor(model => model.Guestsnumber,guests.ToString(),@readonly = "readonly" } })
@Html.ValidationmessageFor(model => model.Guestsnumber,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Name,htmlAttributes: new { @class = "control-label" })
<div class="col-md-10">
@Html.EditorFor(model => model.Name,new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationmessageFor(model => model.Name,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Email,htmlAttributes: new { @class = "control-label" })
<div class="col-md-10">
@Html.EditorFor(model => model.Email,new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationmessageFor(model => model.Email,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Mobile,htmlAttributes: new { @class = "control-label" })
<div class="col-md-10">
@Html.EditorFor(model => model.Mobile,new { htmlAttributes = new { @class = "form-control" } })
@Html.ValidationmessageFor(model => model.Mobile,new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.Message,htmlAttributes: new { @class = "control-label" })
<div class="col-md-10">
@Html.TextAreaFor(model => model.Message,@rows = 5 } })
</div>
</div>
</div>
<div class="modal-footer">
@*<button type="submit" class="btn btn-primary" onclick="function(){alert(" dsdsdsds")};">Send message</button>*@
<button type="button" class="btn btn-primary sendButtonDYNAMICSUFFIX - platinum or gold based on click button">Send message</button>
</div>
</form>
</div>
</div>
</div>
问题:
-
如何将变量或字符串传递给我的模态,将哪个按钮或变量称为模态?例如,我有铂金和金蟾蜍,因此我很想出现在模式欢迎
的标题中Gold memeber
或Welcome platinum memeber
- 当用户单击“发送预订”按钮时,我想阻止引导成功或错误警报。但是我试图将js代码放到我的父页面中,似乎无法识别它?甚至模态html代码都在其父代的同一个类中?
主要思想是,当用户单击“发送预订”时,它会触发对我的HttpGet(也许是发布)控制器的ajax调用,并发送电子邮件(与我的托管邮件服务器映射)。
这是我的控制者:
public bool SendMessage(ClientModel msgModel)
{
try
{
SmtpClient smtpClient = new SmtpClient("smtp.gmail.com",587);
smtpClient.Credentials = new NetworkCredential("xxx@xxx.com","xxxxx");
smtpClient.UseDefaultCredentials = true;
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpClient.EnableSsl = false;
MailMessage mail = new MailMessage();
//Setting From,To and CC
mail.From = new mailaddress(msgModel.Email,"OnyxWeb");
mail.To.Add(new mailaddress("xxx@xxx1.com"));
//mail.CC.Add(new mailaddress("MyEmailID@gmail.com"));
smtpClient.Send(mail);
return true;
}
catch (Exception ex)
{
//throw;
return false;
}
}