Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an iframe where I want to dynamically update the SRC value. I was able to do it with .net framework using the runat=server option. I see runat is not available with .net core 2.0

What I have tried:

I have tried to save the data in a hidden field (successfully) but am unable to change the value of the SRC field
Posted
Updated 31-Dec-17 3:35am

Changing the URL from the client:
HTML
<iframe id="theElement" src="about:blank"></iframe>

<script>
function changeUrl(){
    var iframe = document.getElementById("theElement");
    iframe.src = "https://...";
}
</script>

Changing the URL from the server:
<iframe src="@Model.DocumentUrl"></iframe>
 
Share this answer
 
I have solved the issue, thanks for the insights. I added the iframe in the cshtml text and referenced the iframe src. Below is an example

<svg xmlns="http://www.w3.org/2000/svg" width="500" height="150" viewBox="0 0 500 150">
<rect id="r" width="500" height="150" fill="#fff" />
<line x1="0" y1="130" x2="500" y2="130" stroke="#666" stroke-width="1" stroke-dasharray="3" shape-rendering="crispEdges" pointer-events="none" />
<path id="p" d="@Html.DisplayFor(model => model.imageto_be_displayed")" stroke="navy" stroke-width="2" fill="none" pointer-events="none" />


I populate the image directly from the database, using EntityFramework.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900