Onclick事件后不能立即执行ASP.NET Toaster通知

时间:2017-12-28 18:26:25

标签: asp.net

问题已更新。

参考: http://www.startuppirates.org/blog/gritter/

以下工作正常,点击html链接"添加常规"它显示通知如此相关.js和.css正在运行。

HTML链接

<a href="#" id="add-regular">Add regular notification</a>

的JavaScript

<script type="text/javascript">

    $('#add-regular').click(function () {

        var unique_id = $.gritter.add({
            // (string | mandatory) the heading of the notification
            title: 'This is a regular notice!',
            // (string | mandatory) the text inside the notification
            text: 'This will fade out after a certain amount of time.',
            // (string | optional) the image to display on the left
            image: '/content/gritter/images/success.png',
            // (bool | optional) if you want it to fade out on its own or just sit there
            sticky: false,
            // (int | optional) the time you want it to be alive for before fading out
            time: '',
            class_name: 'gritter-info'
        });
        return false;
    });

</script>

我已经将上面的JS修改为带参数的函数,并且我试图调用它来显示代码隐藏的通知(asp.net / web-forms)但是它无效!

代码隐藏

Page.ClientScript.RegisterStartupScript(Me.GetType(), "return", "stickyalert('Property Upload', 'property data uploaded successfully', 0, 'success');", True)

的JavaScript

<script type="text/javascript">
    function stickyalert(title, text, sticky, success) {
        var unique_id = $.gritter.add({
            // (string | mandatory) the heading of the notification
            title: title,
            // (string | mandatory) the text inside the notification
            text: text,
            // (string | optional) the image to display on the left
            image: '/content/gritter/images/success.png',
            // (bool | optional) if you want it to fade out on its own or just sit there
            sticky: sticky,
            // (int | optional) the time you want it to be alive for before fading out
            time: '5000',
            // (string | optional) the class name you want to apply to that specific message
            class_name: 'gritter-info'
        });
        return false;
    }
</script>

0 个答案:

没有答案