2

I'm using Telerik controls in my project and I am using RadTabStrip for my purposes

<telerik:RadTabStrip ID="tsRequisitions" Skin="" MultiPageID="mpRequisitions" runat="server" Width="980"  ScrollButtonsPosition="Right" ScrollChildren="True" OnTabCreated="tabCreated">

As you can see in this template I call tabCreated method every time when new tab has created. Now I want to call some javascript function from server-side(all mentioned is in RadAjaxPanel).

I've tried to use RegisterClientScriptBlock, but it didn't help me to fire my javascript function.

if (!ClientScript.IsClientScriptBlockRegistered("tabSelected"))
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(),
                    "tabSelected", "TabSelected();", true);
            }

And I have this in my .aspx file

<script type="text/javascript">
    function TabSelected() {
       console.log("dfgdfgfdg");
    }          
</script>

How can I call my function from code-behind after AJAX postback?

3
  • 1
    have you tried RegisterStartupScript instead? Commented Jan 10, 2013 at 14:08
  • If you are rendering HTML, then you can try having the http post response render "<script>TabSelected();</script>". When the browser renders the html it will execute the javascript method. Commented Jan 10, 2013 at 14:14
  • @ChuckNorris - What about ScriptManager.RegisterStartupScript? Commented Jan 10, 2013 at 14:38

2 Answers 2

4

The following code snippet do the trick

RadScriptManager.RegisterStartupScript(this,this.GetType(), "tabSelectedScript", "TabSelected();", true);

RegisterStartupScript is static method of RadScriptManager class (I'm using Telerik controls here again, but maybe it will work with asp.net standart ScriptManager too).

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

Comments

0

Have you tried this ?

    Page.RegisterStartupScript("OnLoad", "<script>TabSelected();</script>");

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.