我正在尝试发送一个javascript到页面的加载器后,一个按钮点击。
按钮也在网格视图中,所以我不确定如何做OnClientClick,但我认为我可以从vb.net后端做,所以我尝试这样做:
If (e.CommandName = "View") Then
Dim row2 As GridViewRow = CType(CType(e.CommandSource, Button).NamingContainer, GridViewRow)
If (Not (row2) Is Nothing) Then
Dim DateSaved As String = row2.Cells(0).Text
Dim javaScript As New System.Text.StringBuilder()
javaScript.Append("<script type=""text/javascript"">" + Constants.vbLf)
javaScript.Append("function ShowProgress() {" + Constants.vbLf)
javaScript.Append("window.onload = function()" + Constants.vbLf)
javaScript.Append("setTimeout(function () {" + Constants.vbLf)
javaScript.Append("var modal = $('<div />');" + Constants.vbLf)
javaScript.Append("modal.addClass(""modal"");" + Constants.vbLf)
javaScript.Append("$('body').append(modal);" + Constants.vbLf)
javaScript.Append("var loading = $("".loading"");" + Constants.vbLf)
javaScript.Append("loading.show();" + Constants.vbLf)
javaScript.Append("var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);" + Constants.vbLf)
javaScript.Append("var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);" + Constants.vbLf)
javaScript.Append("loading.css({ top: top, left: left });" + Constants.vbLf)
javaScript.Append("}, 200);" + Constants.vbLf)
javaScript.Append("}" + Constants.vbLf)
javaScript.Append("$('form').live(""submit"", function () {" + Constants.vbLf)
javaScript.Append("ShowProgress();" + Constants.vbLf)
javaScript.Append("});" + Constants.vbLf)
javaScript.Append("</script>" + Constants.vbLf)
Me.RegisterStartupScript("LoadScript", javaScript.ToString())发布于 2015-08-20 07:41:35
window.onload而不是jQuery的document.ready()?无论如何,您应该使用ASP.NET内置控件来完成此UpdateProgress
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
Processing...
</ProgressTemplate>
</asp:UpdateProgress>只需确保您的网格视图是围绕在UpdatePanel周围的,并且UpdateProgress将在每次发生回发时显示它的模板。
https://stackoverflow.com/questions/32106827
复制相似问题