Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
1
Answer
How to get URL for your crystalreport download?
Guest User
4y
583
1
Reply
Hi Team
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;
// HomeController
//GET/Download_Report
public
ActionResult Download_ExcelReport()
{
//var _db = new eNtsaRegistration();
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);
// rpt.Refresh();
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();
}
}
// View of Download_XMLReport
@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>
// View Form
@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 () {
//When the blur event occurs from your Textbox (you lose focus)
$(
'#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"
;
}
});
});
// Error message for cell-phone.
$(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"
;
}
});
});
// Error message for ZipCode.
$(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>
Post
Reset
Cancel
Answers (
1
)
Next Recommended Forum
What is right assembly for crystalreportViewer in asp.net?
ViewBag and/or Tempdata not showing