I have two buttons like this:
<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>
and I have a modal inside same cshtml class:
<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, new { htmlAttributes = new { @class = "form-control", @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(), new { htmlAttributes = new { @class = "form-control", @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, new { htmlAttributes = new { @class = "form-control", @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>
Questions:
How to pass to my modal a variable or string from which button is called modal? I have for example platinum and gold buttoons, and therefore I wolud like to present in a header of a modal Welcome
Gold memeber
orWelcome platinum memeber
- I want to prevew bootstrap success or error alert when user clicks on send reservation button. But I tried to put js code into my parent page and it seems it cant recognize it? even the modal html code is in the same class of its parent?
the main idea is to when user click send reservation it triggers an ajax call to my HttpGet (maybe post) controller, and sends email (mapped with my hosting mail servers).
This is my controller:
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;
}
}