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
Athirah Zain
NA
48
436
Display PDF (path location is from server's column)
Dec 10 2020 1:54 AM
I have a problem to display my PDF file in my web page.
I am very new to programming, maybe my method is wrong that is why it can't be displayed.
I am using MVC framework.
My controller's code;
public ActionResult ViewPDF(string SelectedStandard)
{
var smlPortalDb = new SMLPORTALEntities();
try
{
var pdfLocation = smlPortalDb.SML_Std_Procedures
.Where(a => a.StandardOperation == SelectedStandard)
.Select(a => a.FilePath)
.FirstOrDefault();
var data = new { pdfLocation, Msg = "OK" };
return Json(data, JsonRequestBehavior.AllowGet);
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
}
Here is my code inside .js file (in Script):
self.SelectedStandard = ko.observable();
self.Search = function () {
if (initialReload)
return;
var SelectedStandard = self.SelectedStandard();
$.ajax({
url: '/General/ViewPDF',
cache: false,
type: 'GET',
data: { SelectedStandard },
success: function (dataServer) {
$("#pdfsource").innerHtml = '<embed style="width:1050px; height: 500px" src="' + dataServer.pdfLocation + '">';
}
});
}
And here is my codes for .html files (in View);
data-bind="click:Search" id="pdfsource" href="~/pdf/MYFILE R0XXXX-XXX PDF TEST.pdf" target="_blank">
Search
I want my PDF to be displayed upon clicking [Search] button.
Can anyone who is expert in this help me please?
Thank you so much in advanced =)
Reply
Answers (
4
)
How to set Tab Index inside the GridView Template Fields?
Debug close itself with Edge and FileUpload