点击按钮后,我试图将javascript发送到装载页面。
该按钮也在gridview中,所以我不确定如何进行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())
答案 0 :(得分:0)
window.onload
而不是jQuery的document.ready()?无论如何,您应该使用ASP.NET内置控件来执行此操作UpdateProgress:
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
Processing...
</ProgressTemplate>
</asp:UpdateProgress>
只需确保您的gridview围绕UpdatePanel,每次发生回发时UpdateProgress都会显示它的模板。