0

I have a function like

                $(function donutchartcreation(numbers) { 

                     alert(numbers[1]); 

                    } 

I tried to call this function from asp.net codebehind pageload as

         int[] numbers = { 27, 20, 30 };
         string serializedNumbers = (new JavaScriptSerializer()).Serialize(numbers);
         System.Web.UI.ScriptManager.RegisterStartupScript(this, this.GetType(), "donutchartcreation", "donutchartcreation( " + serializedNumbers + ");", true);

Here number[1] can not be identified.. Can you plz help me to find the reason?

2 Answers 2

1

Just remove jQuery (i.e $) wrapper. Change

    $(function donutchartcreation(numbers) { 

          alert(numbers[1]); 

     } 

to:

    function donutchartcreation(numbers) {

        alert(numbers[1]);

    }
Sign up to request clarification or add additional context in comments.

Comments

1

you can try as below:

but before that make your javascript function like

javascript

function donutchartcreation(numbers) { 

          alert(numbers[1]); 

     } 

code behind

Page.ClientScript.RegisterStartupScript(this.GetType(), "donutchartcreation", javascript:donutchartcreation('"+ serializedNumbers +"')", true);

i hope it will help you.

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.