0

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.

1 Answer 1

1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.