开发者

Show alert after postback

I have a button which calls stored procedure and binds gridview. I found a code on stackoverflow for top alert bar like开发者_开发百科 this:

function topBar(message) {
        var alert = $('<div id="alert">' + message + '</div>');
        $(document.body).append(alert);
        var $alert = $('#alert');
        if ($alert.length) {
            var alerttimer = window.setTimeout(function () {
                $alert.trigger('click');
            }, 10000);
            $alert.animate({ height: $alert.css('line-height') || '50px' }, 500).click(function () {
                window.clearTimeout(alerttimer);
                $alert.animate({ height: '0' }, 200);
            });
        }
    }

Then in my button I try to call this function like this:

Dim script As String = String.Format("topBar({0});", Server.HtmlEncode("Successfully Inserted"))
        Response.Write(script) 'Or even like this
        ClientScript.RegisterStartupScript(Page.GetType(), "topBar", script, True)

But it simply does not work. Can you guide me in right direction?


I always sort this type of problems with supplying a Boolean Property whether javascript should fire a piece of script or not. For example :

public bool IsDone { get; set; }

Sorry that the code is in C#

This is a property on code behind file. When I need to fire the javascript method, I simply make this true.

What I do on the aspx page is as follows :

<script>    

    if(<%= IsDone.ToString().ToLower() %>) { 
        alert("Done!");
    }

</script>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜