在页面加载时从主页面上的代码调用jQuery函数

时间:2016-06-14 10:18:09

标签: c# jquery asp.net

我在页面加载时从我的母版页中的代码调用了一个jQuery函数,它返回了这个错误:

  

ReferenceError:$未定义

代码背后: -

protected void Page_Load(object sender, EventArgs e)
{   
    string script = "$(document).ready(function () {alert('hello'); });";
    Page.ClientScript.RegisterStartupScript(this.GetType(), "load", script, true);
}

我也试过这个jquery函数: -

ScriptManager.RegisterStartupScript(Page, typeof(Page), "ShowProgressBar", "ShowProgressBar();", true);     

然后得到错误" ShowProgressBar未定义"。

2 个答案:

答案 0 :(得分:0)

试试这个,

import "package:intl/intl_browser.dart";
...
String locale = await findSystemLocale();

答案 1 :(得分:0)

您错过了加载您的jquery文件,在标题中添加以下脚本标记。

<script src="https://code.jquery.com/jquery-3.0.0.min.js"></script>