How to call JavaScript function with value from ASP.NET code behind? I have JavaScript function and I am using it in a div tag
but when i call my function nothing happen ! why ?
( my parameter is path of picture and i want set this path in my div tag to view picture. )
my html code :
<div id="myPano" class="pano">
</div>
my javascript
<script>
function myFunction(imgz) {
$(document).ready(function () {
$("#myPano").pano({
img: imgz
});
});
}
</script>
and code behind ( button click )
Dim imgz As String
imgz = "img/sphere.jpg"
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Script", "myFunction(" & imgz & ")", True)
Thank you.
I can suggest you to add a string to the value:
System.Web.UI.ScriptManager.RegisterClientScriptBlock(Page, GetType(Page), "Script", "myFunction('" & imgz & "')", True)
and you don't have to put your .pano
code inside dom ready:
<script>
function myFunction(imgz) {
$("#myPano").pano({
img: imgz
});
}
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.