TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Zulqadar Idrishi
NA
471
71.3k
Is it bad practice to use JavaScript with Razor Syntax in MVC?
Nov 3 2020 2:39 AM
Hey everyone,
Today, One of the developers of my organization said
"It is a bad practice to use JavaScript with Razor Syntax(c#) in Asp.Net MVC project."
This topic takes lots of discussions but didn't get to any final result. What do you say about it?
Here is the following code that I have used in my Asp.Net MVC Project.
//This is my view.cshtml page
@if (ViewBag.ResponseMessage != null)
{
string ResponseType = @String.IsNullOrEmpty(ViewBag.ResponseType) ? "info" : ViewBag.ResponseType;
string ResponseTitle = @String.IsNullOrEmpty(ViewBag.ResponseTitle) ? "" : ViewBag.ResponseTitle;
<script>
$(document).ready(function () {
swal('
@ViewBag.ResponseMessage
', '
@ResponseTitle
', "
@ResponseType
").then(function () {
@if (!string.IsNullOrEmpty(ViewBag.ResponseURL))
{
@:window.location.href = "@ViewBag.ResponseURL";
}
})
})
</script>
}
Reply
Answers (
1
)
how to download Gridview as excel?
about verification by email