Is there a way to use if else statment inside MVC cshtml page
<div class="primary-content">
if(DetectIE())
{
<embed data-bind="attr: { src: data.files()[currentPage()] + '#toolbar=0&navpanes=0&scrollbar=0' }" type="application/pdf" style="width: 100%; height: 800px !important;">
}
else
{
<object data-bind="attr: { data: data.files()[currentPage()] + '#toolbar=0&navpanes=0&scrollbar=0' }" type="application/pdf" width="100%" height="600px"></object>
}
</div>
I have a javascript code to detect if the current browser is Internet explorer or not . If it is a IE then <embed> tag is used otherwise <object> tag is used.
Any suggestions or help would be appreciated.
Thanks in advance
@if (DetectIE()) { // embed tag } else { // object tag }statement. But what isDetectIE()do?ifstatement. Place the if statement inside the<script>tag and append the element with something like$.append('<embed>...</embed>').Request.Browserto determine the browser in the controller, and then just pass aboolproperty to your view indicating if its IE or not (as a view model property or aViewBagproperty)