0

I need to call a JS function via codebehind when its no postback on a site. I've added my script before the closing <head> Tag:

<script type="text/javascript">
    function StartWidgetTour() {
        //init the tour!
        wWidgetTour.init();

        //finally start the tour! strange but we have to restart.
        wWidgetTour.restart();
    }
</script>

My Code looks like:

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "Widget Tour Start!", "StartWidgetTour()", true);
        //more code that already works

When I want to run this code, I get a built error The name 'ScriptManager' does not exist in the current context.

I am already using namespace System.Web and System.Web.UI;. The answers to this question didn't worked for me.

Thanks for any help!

Community
  • 1
  • 1
Hack4Life
  • 563
  • 1
  • 11
  • 34

1 Answers1

0

Add a scriptmanager to the *.aspx page

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
ajthewebdev
  • 432
  • 2
  • 5
  • 17