How do get URL for your download button if you have Homecontroller? I have created View but i want that download but within my form. Example is below;
-
-
-
- public ActionResult Download_ExcelReport()
- {
-
-
- var data = (from q in db.eNtsaRegForms select new {
- Id = q.Id,
- Title = q.Title,
- FirstName = q.FirstName,
- LastName = q.LastName,
- Position =q.Position,
- Company = q.Company,
- StreetAddress = q.StreetAddress,
- StreetAddressLine = q.StreetAddressLine,
- City = q.City,
- StateProvince = q.StateProvince,
- ZipCode = q.ZipCode,
- Email = q.Email,
- CellNumber = q.CellNumber,
- Country = q.Country,
- DietaryRequirements = q.DietaryRequirements
-
-
- }).ToList();
-
- ReportDocument rpt = new ReportDocument();
- rpt.Load(Server.MapPath("~/Reports/TrainingAcademy.rpt"));
- rpt.SetDataSource(data);
-
-
-
-
- Response.Buffer = false;
- Response.ClearContent();
- Response.ClearHeaders();
-
- try
- {
- Stream stream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
- stream.Seek(0, SeekOrigin.Begin);
- return File(stream, "application/vnd.ms-excel", "eNtsaRegistrationForm.xls");
- }
- catch
- {
- throw;
- return View();
- }
-
-
- }
-
-
- @model eNtsaRegistrationTraining.Models.RegViewAndRoleViewModel
-
- @{
- ViewBag.Title = "Download_ExcelReport";
- }
-
- <h2>Download_ExcelReport</h2>
-
- @using (Html.BeginForm())
- {
- @Html.AntiForgeryToken()
-
- <div class="form-horizontal">
-
- <hr />
- @Html.ValidationSummary(true, "", new { @class = "text-danger" })
- <div class="form-group">
- <div class="col-md-offset-2 col-md-10">
- <input type="submit" value="Create" class="btn btn-default" />
- </div>
- </div>
- </div>
- }
-
- <div>
- @Html.ActionLink("Back to List", "RegFormSave")
- </div>
-
-
- @model eNtsaRegistrationTraining.Models.RegViewAndRoleViewModel
-
- @{
- ViewBag.Title = "SubmitRegDetails";
- List<SelectListItem> CountryLIstData = new List<SelectListItem>();
- foreach (var data in Model.CountryLIst)
- {
- SelectListItem selectList = new SelectListItem();
- selectList.Text = data.Text;
- selectList.Value = data.Value;
- CountryLIstData.Add(selectList);
- }
- }
- @if(User.IsInRole("SuperAdmin")) {
- <center>
- <div class="z-inex" style="width:1000px;">
- <div class="register-logo">
-
- </div>
- <div class="card">
- <div class="card-body register-card-body">
- <center>
- <img src="~/Images/eNtsa.png" />
- </center>
- <center>
- <h1>
- <p><b>Training Course Registration:Motion MasterClass</b></p>
- </h1>
- <hr />
- <p>Course date: 25-27 February 2020</p>
- <hr />
- <p>
- Note:Please note your registration is submit approval as seats for this course is limited. Once your registration is confirmed, you will receive a quote for subject to your confirmation
- followed by an invoice.
- </p>
- </center>
-
-
- <center>
- @using (Html.BeginForm("SubmitRegDetails", "Home", FormMethod.Post))
- {
-
-
- <div class="form-horizontal">
-
- <hr />
-
- <div class="form-group row">
- <label for="Title" class="col-sm-2 col-form-label">Title</label>
- <div class="col-sm-3 ">
- @Html.EditorFor(model => model.RegForm.Title, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.RegForm.Title, "", new { @class = "text-danger" })
-
- </div>
- </div>
-
- <div class="form-group row">
- <label for="Name" class="col-sm-2 col-form-label">Name:</label>
- <div class="col-sm-3 ">
- @Html.EditorFor(model => model.RegForm.FirstName, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Name" } })
- @Html.ValidationMessageFor(model => model.RegForm.FirstName, "", new { @class = "text-danger" })
-
- </div>
-
- <div class="col-sm-3">
- @Html.EditorFor(model => model.RegForm.LastName, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "LastName" } })
- @Html.ValidationMessageFor(model => model.RegForm.LastName, "", new { @class = "text-danger" })
- </div>
- </div>
-
- <div class="form-group row">
- <label for="Position" class="col-sm-2 col-form-label">Position:</label>
- <div class="col-sm-3">
- @Html.EditorFor(model => model.RegForm.Position, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.RegForm.Position, "", new { @class = "text-danger" })
- </div>
- </div>
-
- <div class="form-group row">
- <label for="Company" class="col-sm-2 col-form-label">Company:</label>
- <div class="col-md-3">
- @Html.EditorFor(model => model.RegForm.Company, new { htmlAttributes = new { @class = "form-control" } })
- @Html.ValidationMessageFor(model => model.RegForm.Company, "", new { @class = "text-danger" })
- </div>
- </div>
-
- <div class="form-group row">
- <label for="Addresss" class="col-sm-2 col-form-label">Address*</label>
- <div class="col-sm-5">
- @Html.EditorFor(model => model.RegForm.StreetAddress, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Street Address" } })
- @Html.ValidationMessageFor(model => model.RegForm.StreetAddress, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group row">
- <label for="Address" class="col-sm-2 col-form-label"></label>
- <div class="col-sm-5">
- @Html.EditorFor(model => model.RegForm.StreetAddressLine, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Street Address Line 2" } })
- @Html.ValidationMessageFor(model => model.RegForm.StreetAddressLine, "", new { @class = "text-danger" })
- </div>
- </div>
- <div class="form-group row">
- <label for="City" class="col-sm-2 col-form-label"></label>
- <div class="col-sm-3">
- @Html.EditorFor(model => model.RegForm.City, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "City" } })
- @Html.ValidationMessageFor(model => model.RegForm.City, "", new { @class = "text-danger" })
- </div>
- <label for="State/Province" class="col-form-label"></label>
- <div class="col-sm-3">
- @Html.EditorFor(model => model.RegForm.StateProvince, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "State/Province" } })
- @Html.ValidationMessageFor(model => model.RegForm.StateProvince, "", new { @class = "text-danger" })
- </div>
-
- </div>
- <div class="form-group row">
- <label for="ZipCode" class="col-sm-2 col-form-label"></label>
- <div class="col-sm-3">
- @Html.EditorFor(model => model.RegForm.ZipCode, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "ZipCode", id = "textZipCode" } })
- @Html.ValidationMessageFor(model => model.RegForm.ZipCode, "", new { @class = "text-danger" })
- </div>
- @using (Html.BeginForm("Index", "Home", FormMethod.Post))
- {
- <div class="col-sm-3">
- @Html.DropDownListFor(model => model.RegForm.Country, CountryLIstData as List<SelectListItem>)
- </div>
- }
-
- </div>
-
- <div class="form-group row">
- <label for="Email" class="col-sm-2 col-form-label">Email:</label>
-
- <div class="col-sm-4">
- @Html.EditorFor(model => model.RegForm.Email, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Email", id = "textEmail" } })
- @Html.ValidationMessageFor(model => model.RegForm.Email, "", new { @class = "text-danger" })
- </div>
- <label id="labelMessage_email" class="text-danger" style="display:none">This field is required</label>
- </div>
-
- <div class="form-group row">
- <label for="Attendee" class="col-sm-2 col-form-label">Attendee Cell Number*</label>
- <div class="col-sm-3">
- @Html.EditorFor(model => model.RegForm.CellNumber, new { htmlAttributes = new { @class = "form-control", autofocus = "autofocus", placeholder = "Cell Number", id = "textCellNumber" } })
- @Html.ValidationMessageFor(model => model.RegForm.CellNumber)
- </div>
-
- </div>
-
- <div class="form-group row">
- <label for="Verify not a human" class="col-sm-2 col-form-label">Please verify you not a human*</label>
- <div class="col-sm-3">
- @using (Html.BeginForm("FormSubmit", "GetCapatcha", FormMethod.Post))
- {
- <div class="g-recaptcha" data-sitekey="6LcLN6cZAAAAABbgHtWziQB9nsWNXqZcpBnLU6dd">
-
- </div>
- }
- </div>
- </div>
-
- <div class="form-group row">
- <label class="col-sm-2 col-form-label">Dietary requirements:</label>
- <div class="col-sm-3">
- <div class="form-check">
- @Html.CheckBoxFor(model => model.DietMain.None, new { @class = "form-check-input" })
- <label class="form-check-label" for="@Html.IdFor(m => m.DietMain.None)">None</label>
- </div>
- <div class="form-check">
- @Html.CheckBoxFor(model => model.DietMain.Vegetarian, new { @class = "form-check-input" })
- <label class="form-check-label" for="@Html.IdFor(m => m.DietMain.Vegetarian)">Vegetarian</label>
- </div>
-
- <div class="form-check">
- @Html.CheckBoxFor(model => model.DietMain.Vegan, new { @class = "form-check-input" })
- <label class="form-check-label" for="@Html.IdFor(m => m.DietMain.Vegan)">Vegan</label>
- </div>
-
- <div class="form-check">
- @Html.CheckBoxFor(model => model.DietMain.Halaal, new { @class = "form-check-input" })
- <label class="form-check-label" for="@Html.IdFor(m => m.DietMain.Halaal)">Halaal</label>
- </div>
-
- <div class="form-check">
- @Html.CheckBoxFor(model => model.DietMain.Other, new { @class = "form-check-input" })
- <label class="form-check-label" for="@Html.IdFor(m => m.DietMain.Other)">Other</label>
- </div>
-
- </div>
- </div>
-
- <div class="form-group">
- <div class="col-md-offset-2 col-md-10">
- <input type="submit" value="Submit" class="btn btn-primary" />
- </div>
-
- </div>
- <div class="form-group">
- <div class="col-md-offset-2 col-md-10">
- <input type="submit" value="Download" class="btn btn-danger" />
- </div>
- </div>
- </div>
-
-
-
- }
- <div>
- @Html.ActionLink("Back to list", "SaveRegForm")
- </div>
- </center>
- </center>
- }
- <span style="font-size:20px;margin:20px;padding:20px;border:1px; solid#ff0000">
- @ViewData["Message"]
- </span>
- <script src='https://www.google.com/recaptcha/api.js' type="text/javascript"></script>
-
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
-
-
-
- <!--Handling form-validation when empty-->
- <script type='text/javascript'>
- $(function () {
-
- $('#textEmail').blur(function () {
- var email = document.getElementById("textEmail").value;
- var expr = /[a-z0-9._%+-]+[a-z0-9.-]+\.[a-z]{2,}$/;
- if (!expr.test(email)) {
- document.getElementById("labelMessage_email").style.display = "inline";
- }
- else {
- document.getElementById("labelMessage_email").style.display = "none";
- }
- });
- });
-
-
- $(function () {
- $('#textCellNumber').blur(function () {
- var cell = document.getElementById("textCellNumber").value;
- var expr = /[a-z0-9._%+-]+[a-z0-9.-]+\.[a-z]{2,}$/;
- if (!expr.test(cell)) {
- document.getElementById("labelMessage_cell").style.display = "inline";
- } else {
- document.getElementById("labelMessage_cell").style.display = "none";
- }
- });
-
- });
-
-
-
- $(function () {
- $('#textZipCode').blur(function () {
- var zipcode = document.getElementById("textZipCode").value;
- var expr = /[a-z0-9._%+-]+[a-z0-9.-]+\.[a-z]{2,}$/;
- if (!expr.test(zipcode)) {
- document.getElementById("labelMessage_zip").style.display = "inline";
- } else {
- document.getElementById("labelMessage_zip").style.display = "none";
- }
- });
- });
- </script>
-