How can I call a JS function via codebehind without postback on a site?
I've placed my script before the closing <head>
Tag:
<script type="text/javascript">
function StartWidgetTour() {
//initialize the tour
wWidgetTour.init();
//start the tour
wWidgetTour.restart();
}
</script>
This is how 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 working code here
However, when I try to run this code, I get the error message:
The name 'ScriptManager' does not exist in the current context
.
I have already included the namespaces System.Web
and System.Web.UI;
.
The solutions provided in this question did not work for me.
Any assistance would be greatly appreciated!