Skip to content

Instantly share code, notes, and snippets.

@rsciriano
Created January 29, 2016 19:40
Show Gist options
  • Save rsciriano/bf1332cac4aa058c8857 to your computer and use it in GitHub Desktop.
Save rsciriano/bf1332cac4aa058c8857 to your computer and use it in GitHub Desktop.
Conflicto entre GridViewScroll y Loading image en ASP.NET WebForms
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="GridPage.aspx.cs" Inherits="PruebaGridViewScroll.GridPage" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<style type="text/css">
.modal {
position: fixed;
top: 0;
left: 0;
background-color: black;
z-index: 99;
opacity: 0.8;
filter: alpha(opacity=80);
-moz-opacity: 0.8;
min-height: 100%;
width: 100%;
}
.loading
{
font-family: Arial;
font-size: 10pt;
border: 5px solid #67CFF5;
width: 200px;
height: 100px;
display: none;
position: fixed;
background-color: White;
z-index: 999;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Button ID="Button1" runat="server" Text="Actualizar" />
</div>
<asp:GridView ID="GridView1" runat="server">
</asp:GridView>
<div class="loading" align="center">
Loading. Please wait.<br />
<br />
<img src="Content/Images/loader.gif" alt="" />
</div>
</form>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.1/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://gridviewscroll.aspcity.idv.tw/Scripts/gridviewScroll.min.js?20130319"></script>
<script type="text/javascript">
$(document).ready(function () {
gridviewScroll();
$('form').live("submit", function () {
ShowProgress();
});
});
function gridviewScroll() {
$('#<%=GridView1.ClientID%>').gridviewScroll({
width: 400,
height: 200,
freezesize: 1
});
}
function ShowProgress() {
setTimeout(function () {
var modal = $('<div />');
modal.addClass("modal");
$('body').append(modal);
var loading = $(".loading");
loading.show();
var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0);
var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0);
loading.css({ top: top, left: left });
}, 200);
}
</script>
</body>
</html>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace PruebaGridViewScroll
{
public partial class GridPage : System.Web.UI.Page
{
public class Customer
{
public int Id { get; set; }
public string Name { get; set; }
public string Country { get; set; }
}
protected void Page_Load(object sender, EventArgs e)
{
var customers = new List<Customer>();
for (int i = 1; i <= 100; i++)
{
customers.Add(new Customer { Id = i, Name = $"Customer {i}", Country = "Spain" });
}
GridView1.DataSource = customers;
GridView1.DataBind();
Thread.Sleep(5000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment