Search code examples
javascriptjqueryasp.netcode-behind

How do I call javascript function from codebehind with ClientScript


Possible Duplicate:
How to call javascript function from code-behind

I have an empty div that I want to be adding check boxes to if a code behind boolean is true.

Here is the div:

<div id="checkboxes" />

Here is my javascript function:

        <script type="text/javascript">
        function addCheckboxes() {
            alert("just an alert for now");
        }

And here is my code behind where I want to call the "addCheckboxes" function:

bool isMovingTask = Convert.ToBoolean(Request.QueryString["isMovingTask"].ToString());
        if (isMovingTask)
        {
            //call javascript function
        }

Solution

  • See related answer here: How to call javascript function from code-behind

    Basically you want to make a call to register your client script, there are a few ways to do this in .NET.