title: PageRequestManagerServerErrorException object reference not set... ASP.net AJAX
body: <p>Is anyone able to understand why m I getting this error?</p>
  
  <p>Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: Object reference not set to an instance of an object.</p>
  
  <p>SOURCE: ScriptResource.axd</p>
  
  <p>So here is the thing...</p>
  
  <p>I have a button when first clicked (after first site access) works, but after that I always get the error. I tried to debug the subject by putting a debug point at the first line in Page_Load event but its not even getting there. </p>
  
  <p>The error is showing before that on that ScriptResources.axd file which is made of javascript so i tried to debug it but i don't really understand what is going on so i couldn't find the problem.</p>
  
  <p>From what i can understand, somehow, when i first click the button, i must not being initialize some controll i should, but i just can't figure it out.</p>
  
  <p>button id = btnFiltra</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;body&gt;
      &lt;form id="form1" runat="server"&gt;
      &lt;asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"&gt;
      &lt;/asp:ToolkitScriptManager&gt;
      &lt;script type="text/javascript"&gt;
          Sys.Application.add_load(onPageLoad);
      &lt;/script&gt;
      &lt;asp:Panel runat="server" ID="pHeader" CssClass="PVHeaderBackground"&gt;
          &lt;img alt="Planview" src="Images/logo_planview.png" class="PVLogoBackImgleft"/&gt;
          &lt;div id="PTLogo" class="PTLogosRight"&gt;
              &lt;img src="Images/logo_meo_preto.png" alt="Meo" style="vertical-align:middle; margin-top:auto; margin-bottom:auto"/&gt;
              &lt;img src="Images/Ptlogo.jpg" alt="PT" style="height:50px; width:auto; margin-left:10px; vertical-align:middle;margin-top:auto; margin-bottom:auto"/&gt;
          &lt;/div&gt;
      &lt;/asp:Panel&gt;
      &lt;asp:UpdatePanel ID="upBody" runat="server" UpdateMode="Conditional" &gt;
          &lt;ContentTemplate&gt;
          &lt;asp:Panel runat="server" ID="pOpcoesGlobais" &gt;
              &lt;asp:Button ID="btnExtrair" runat="server" OnClientClick="umProjetoApenas()" OnClick="btnExtrair_OnClick" Text="Extrair Dados"/&gt;
              &lt;asp:Button ID="btnAtualizar" runat="server" OnClientClick="umProjetoApenas()" OnClick="btnAtualizar_OnClick" Text="Atualizar Dados"/&gt;
          &lt;/asp:Panel&gt;
          &lt;asp:Panel runat="server" ID="pTarefaOkFaturar" Visible="true" style="display:none;" Width="100%" Height="100%" &gt;
              &lt;div style="width:100%; height:10%"&gt;
                  &lt;b&gt;Ao confirmar que a tarefa pode ser faturada, todas as parcelas sem documento passarão a ser faturadas de forma automática.&lt;/b&gt;
              &lt;/div&gt;
              &lt;div style="width:100%;"&gt;
                  &lt;asp:GridView runat="server" ID="gvCheckParcelas" CssClass="PVPortlet"&gt;&lt;/asp:GridView&gt;
              &lt;/div&gt;
              &lt;div style="width:100%;position: absolute;bottom: 10px;"&gt;
                  &lt;asp:Button ID="btnOkFaturarCancelar" runat="server" Text="Cancelar" OnClick="btnOkFaturarCancelar_OnClick" style="float:left;margin-left: 10px;"/&gt;
                  &lt;asp:Button ID="btnOkFaturarOk" runat="server" Text="Concordo" OnClick="btnOkFaturarOk_OnClick" style="float:right;margin-right: 10px;" /&gt;
              &lt;/div&gt;
          &lt;/asp:Panel&gt;
          &lt;asp:Panel runat="server" ID="pBody"&gt;
              &lt;asp:UpdatePanel ID="upFiltros" runat="server"&gt;
                  &lt;ContentTemplate&gt;
                      &lt;asp:Label ID="lCliente" runat="server" Text="Cliente"/&gt;               
                      &lt;asp:TextBox ID="txbCliente" runat="server"/&gt;
                      &lt;asp:PopupControlExtender ID="txbCliente_PopupControlExtender" runat="server" Enabled="True" ExtenderControlID="" TargetControlID="txbCliente" 
                          PopupControlID="pPopUpCliente" Position="Bottom" &gt;
                      &lt;/asp:PopupControlExtender&gt;
                      &lt;asp:Panel ID="pPopUpCliente" runat="server" Height="116px" BorderStyle="Solid" BorderWidth="2px" Direction="LeftToRight" ScrollBars="Auto" BackColor="#CCCCCC" Style="display: none" &gt;
                          &lt;asp:CheckBoxList ID="cblCliente" runat="server" DataTextField="DESCRICAO" onChange="uncheckOnTodos(this)" DataValueField="ID" AutoPostBack="False" AppendDataBoundItems="True"&gt;
                               &lt;asp:ListItem Text="Todos" Value="all" Selected="False"&gt;&lt;/asp:ListItem&gt;
                          &lt;/asp:CheckBoxList&gt;
                      &lt;/asp:Panel&gt;
                      &lt;asp:Label ID="lPedido" runat="server" Text="Pedido"/&gt;
                      &lt;asp:TextBox ID="txbPedido" runat="server"/&gt;
                      &lt;asp:PopupControlExtender ID="txbPedido_PopupControlExtender" runat="server"
                          Enabled="True" ExtenderControlID="" TargetControlID="txbPedido" 
                          PopupControlID="pPopUpPedido" Position="Bottom" &gt;
                      &lt;/asp:PopupControlExtender&gt;
                      &lt;asp:Panel ID="pPopUpPedido" runat="server" Height="116px" 
                           BorderStyle="Solid" BorderWidth="2px" Direction="LeftToRight"
                           ScrollBars="Auto" BackColor="#CCCCCC" Style="display: none" &gt;
                          &lt;asp:CheckBoxList ID="cblPedido" runat="server" 
                               DataTextField="DESCRICAO" onChange="uncheckOnTodos(this)"
                               DataValueField="ID" AutoPostBack="False" AppendDataBoundItems="True"&gt;
                               &lt;asp:ListItem Text="Todos" Value="all" Selected="False"&gt;&lt;/asp:ListItem&gt;
                          &lt;/asp:CheckBoxList&gt;
                      &lt;/asp:Panel&gt;
                      &lt;asp:Label ID="lProjeto" runat="server" Text="Projeto"/&gt;
                      &lt;asp:TextBox ID="txbProjeto" runat="server"/&gt;
  
                      &lt;asp:PopupControlExtender ID="txbProjeto_PopupControlExtender" runat="server"
                          Enabled="True" ExtenderControlID="" TargetControlID="txbProjeto" 
                          PopupControlID="pPopUpProjeto" Position="Bottom" &gt;
                      &lt;/asp:PopupControlExtender&gt;
                      &lt;asp:Panel ID="pPopUpProjeto" runat="server" Height="116px" 
                           BorderStyle="Solid" BorderWidth="2px" Direction="LeftToRight" ScrollBars="Auto" BackColor="#CCCCCC" Style="display: none" &gt;
                          &lt;asp:CheckBoxList ID="cblProjeto" runat="server" 
                               DataTextField="DESCRICAO" onChange="uncheckOnTodos(this)"
                               DataValueField="ID" AutoPostBack="False" AppendDataBoundItems="True"&gt;
                               &lt;asp:ListItem Text="Todos" Value="all" Selected="False"&gt;&lt;/asp:ListItem&gt;
                          &lt;/asp:CheckBoxList&gt;
                      &lt;/asp:Panel&gt;
                      &lt;asp:Button runat="server" ID="btnFiltra" Text="Pesquisar" 
                          onclick="btnFiltra_Click"/&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
              &lt;asp:UpdateProgress ID="uprgTarefas" runat="server" AssociatedUpdatePanelID="upTarefas" DisplayAfter="2000" &gt;
                  &lt;ProgressTemplate&gt;Loading...&lt;/ProgressTemplate&gt;
              &lt;/asp:UpdateProgress&gt;
              &lt;asp:UpdatePanel ID="upTarefas" runat="server"&gt;
                  &lt;Triggers&gt;
                      &lt;asp:AsyncPostBackTrigger ControlID="btnFiltra" EventName="Click" /&gt;
                      &lt;asp:AsyncPostBackTrigger ControlID="btnAtualizar" EventName="Click" /&gt;
                      &lt;asp:AsyncPostBackTrigger ControlID="btnExtrair" EventName="Click" /&gt;
                  &lt;/Triggers&gt;
                  &lt;ContentTemplate&gt;
                      &lt;div id="dTabelaTarefaHeader" class="PVPortletHeader"&gt;
                          &lt;div id="dTabelaTarefasOpcoes" class="PVPortletHeaderOpcoes"&gt;&lt;/div&gt;
                          &lt;b&gt;Tarefas Faturação&lt;/b&gt;
                      &lt;/div&gt;
                      &lt;asp:Panel runat="server" ID="pgvTarefasEmpty" Visible="false"&gt;
                          &lt;table class="PVPortlet"&gt;
                               &lt;tbody&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;&lt;/th&gt;
                                      &lt;th&gt;ID&lt;/th&gt;
                                      &lt;th&gt;Projeto&lt;/th&gt;
                                      &lt;th&gt;Tarefa&lt;/th&gt;
                                      &lt;th&gt;Cliente&lt;/th&gt;
                                      &lt;th&gt;Pedido&lt;/th&gt;
                                      &lt;th&gt;Inicio&lt;/th&gt;
                                      &lt;th&gt;Fim&lt;/th&gt;
                                      &lt;th&gt;Faturar?&lt;/th&gt;
                                      &lt;th&gt;Planeado&lt;/th&gt;
                                      &lt;th&gt;Remanescente&lt;/th&gt;
                                      &lt;th&gt;Faturado&lt;/th&gt;
                                      &lt;th&gt;Entidade&lt;/th&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan="13"&gt;Sem dados...&lt;/td&gt;
                                  &lt;/tr&gt;
                               &lt;/tbody&gt;                   
                          &lt;/table&gt;
                      &lt;/asp:Panel&gt;
                      &lt;asp:GridView ID="gvTarefas" runat="server" AutoGenerateSelectButton="true" 
                          AutoGenerateColumns="false" CssClass="PVPortlet" SelectedRowStyle-CssClass="PVPortletSelectedRow"
                          onselectedindexchanged="gvTarefas_SelectedIndexChanged" DataKeyNames="ID"
                          OnRowCreated="gvTarefas_OnRowCreated"&gt;
                          &lt;columns&gt;
                              &lt;asp:BoundField DataField="ID" HtmlEncode="false" HeaderText="ID" /&gt;
                              &lt;asp:BoundField DataField="Projeto" HtmlEncode="false" HeaderText="Projeto" /&gt;
                              &lt;asp:BoundField DataField="Tarefa" HtmlEncode="false" HeaderText="Tarefa" /&gt;
                              &lt;asp:BoundField DataField="Cliente" HtmlEncode="false" HeaderText="Cliente" /&gt;
                              &lt;asp:BoundField DataField="Pedido" HtmlEncode="false" HeaderText="Pedido" /&gt;
                              &lt;asp:BoundField DataField="DataInicio" DataFormatString="{0:dd-MM-yyyy}" HeaderText="Inicio" /&gt;
                              &lt;asp:BoundField DataField="DataFim" DataFormatString="{0:dd-MM-yyyy}" HeaderText="Fim" /&gt;
                              &lt;asp:TemplateField HeaderText="Faturar?"&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:CheckBox runat="server" ID="cbFaturar" Checked='&lt;%# Eval("ProntoAFaturar") %&gt;' AutoPostBack="true" OnCheckedChanged="cb_OnCheckedChanged"/&gt;
                                  &lt;/ItemTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                              &lt;asp:BoundField DataField="Planeado" HeaderText="Planeado" /&gt;
                              &lt;asp:BoundField DataField="Remanescente" HeaderText="Remanescente" /&gt;
                              &lt;asp:BoundField DataField="Faturado" HeaderText="Faturado" /&gt;
                              &lt;utl:CompositeBoundField HeaderText="Entidade" DataField="EntidadeResponsavel.Descricao" /&gt;
                          &lt;/columns&gt;
                      &lt;/asp:GridView&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
              &lt;br /&gt;
              &lt;br /&gt;
              &lt;asp:UpdateProgress ID="uprgParcelas" runat="server" 
                  AssociatedUpdatePanelID="upParcelas" DisplayAfter="2000"&gt;
                  &lt;ProgressTemplate&gt;Loading...&lt;/ProgressTemplate&gt;
              &lt;/asp:UpdateProgress&gt;
              &lt;asp:UpdatePanel ID="upParcelas" runat="server" UpdateMode="Conditional"&gt;
                  &lt;Triggers&gt;
                      &lt;asp:asyncpostbacktrigger controlid="gvTarefas" 
                          EventName="SelectedIndexChanged" /&gt;
                      &lt;asp:asyncpostbacktrigger controlid="gvParcelas" EventName="RowEditing" /&gt;
                  &lt;/Triggers&gt;
                  &lt;ContentTemplate&gt;
                      &lt;div ID="dTabelaParcelasHeader" class="PVPortletHeader"&gt;
                          &lt;b&gt;Parcelas Faturação&lt;/b&gt;
                      &lt;/div&gt;
                      &lt;asp:Panel ID="pgvParcelasEmpty" runat="server" Visible="false"&gt;
                          &lt;table class="PVPortlet"&gt;
                              &lt;tbody&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;&lt;/th&gt;
                                      &lt;th&gt;ID&lt;/th&gt;
                                      &lt;th&gt;Auto&lt;/th&gt;
                                      &lt;th&gt;DataEnvio&lt;/th&gt;
                                      &lt;th&gt;Descrição&lt;/th&gt;
                                      &lt;th&gt;Valor&lt;/th&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan="6"&gt;Sem dados...&lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/tbody&gt;
                          &lt;/table&gt;
                      &lt;/asp:Panel&gt;
                      &lt;asp:GridView ID="gvParcelas" runat="server"   AutoGenerateColumns="false" AutoGenerateDeleteButton="true"  AutoGenerateEditButton="true"AutoGenerateSelectButton="true"  CssClass="PVPortlet" DataKeyNames="ID"  OnRowCancelingEdit="gvParcelas_OnRowCancelingEdit" 
  OnRowCommand="gvParcelas_OnRowCommand"  OnRowCreated="gvParcelas_OnRowCreated" OnRowDeleting="gvParcelas_OnRowDeleting"  OnRowEditing="gvParcelas_RowEditing" OnRowUpdating="gvParcelas_OnRowUpdating"  Visible="false" SelectedRowStyle-CssClass="PVPortletSelectedRow"
  OnSelectedIndexChanged="obterDocumento_OnSeacrh" ShowFooter="True"&gt;
                          &lt;Columns&gt;
                              &lt;asp:TemplateField HeaderText="ID"&gt;
                                  &lt;EditItemTemplate&gt;
                                      &lt;asp:Label ID="lIDParcela" runat="server" Text='&lt;%# Eval("ID") %&gt;' /&gt;
                                  &lt;/EditItemTemplate&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:Label ID="lIDParcela" runat="server" Text='&lt;%# Eval("ID") %&gt;' /&gt;
                                  &lt;/ItemTemplate&gt;
                                  &lt;FooterTemplate&gt;
                                      &lt;asp:Button ID="btnParcelaNovo" runat="server" CommandName="Insert" Text="Novo" /&gt;
                                  &lt;/FooterTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                              &lt;asp:TemplateField HeaderText="Auto"&gt;
                                  &lt;EditItemTemplate&gt;
                                      &lt;asp:CheckBox ID="cbAuto" runat="server" Checked='&lt;%# Eval("Auto") %&gt;' /&gt;
                                  &lt;/EditItemTemplate&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:CheckBox ID="cbAuto" runat="server" Checked='&lt;%# Eval("Auto") %&gt;' Enabled="false"/&gt;
                                  &lt;/ItemTemplate&gt;
                                  &lt;FooterTemplate&gt;
                                      &lt;asp:CheckBox ID="cbAuto" runat="server" Checked="true" /&gt;
                                  &lt;/FooterTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                              &lt;asp:TemplateField HeaderText="DataEnvio"&gt;
                                  &lt;EditItemTemplate&gt;
                                      &lt;asp:TextBox ID="txbDataEnvio" runat="server" Text='&lt;%# Eval("DataEnvio","{0:dd-MM-yyyy}") %&gt;' /&gt;
                                      &lt;asp:CalendarExtender ID="txbDataEnvio_CalendarExtender" runat="server" 
                                          DefaultView="Months" Enabled="True" Format="MM-yyyy" PopupPosition="BottomLeft" 
                                          TargetControlID="txbDataEnvio"&gt;
                                      &lt;/asp:CalendarExtender&gt;
                                  &lt;/EditItemTemplate&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:Label ID="lDataEnvio" runat="server" 
                                          Text='&lt;%# Eval("DataEnvio","{0:dd-MM-yyyy}") %&gt;' /&gt;
                                  &lt;/ItemTemplate&gt;
                                  &lt;FooterTemplate&gt;
                                      &lt;asp:TextBox ID="txbDataEnvio" runat="server" Text="" /&gt;
                                      &lt;asp:CalendarExtender ID="txbDataEnvio_CalendarExtender" runat="server" 
                                          DefaultView="Months" Enabled="True" Format="MM-yyyy" PopupPosition="BottomLeft" 
                                          TargetControlID="txbDataEnvio"&gt;
                                      &lt;/asp:CalendarExtender&gt;
                                  &lt;/FooterTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                              &lt;asp:TemplateField HeaderText="Descrição"&gt;
                                  &lt;EditItemTemplate&gt;
                                      &lt;asp:TextBox ID="txbDescricao" runat="server" Text='&lt;%# Eval("Descricao") %&gt;' /&gt;
                                  &lt;/EditItemTemplate&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:Label ID="lDescricao" runat="server" Text='&lt;%# Eval("Descricao") %&gt;' /&gt;
                                  &lt;/ItemTemplate&gt;
                                  &lt;FooterTemplate&gt;
                                      &lt;asp:TextBox ID="txbDescricao" runat="server" Text="" /&gt;
                                  &lt;/FooterTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                              &lt;asp:TemplateField HeaderText="Valor"&gt;
                                  &lt;EditItemTemplate&gt;
                                      &lt;asp:TextBox ID="txbValor" runat="server" Text='&lt;%# Eval("Valor") %&gt;' /&gt;
                                      &lt;asp:FilteredTextBoxExtender ID="txbValor_FilteredTextBoxExtender" runat="server" FilterType="Custom" TargetControlID="txbValor" ValidChars="0123456789,"&gt;
                                      &lt;/asp:FilteredTextBoxExtender&gt;
                                  &lt;/EditItemTemplate&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:Label ID="lValor" runat="server" Text='&lt;%# Eval("Valor") %&gt;' /&gt;
                                  &lt;/ItemTemplate&gt;
                                  &lt;FooterTemplate&gt;
                                      &lt;asp:TextBox ID="txbValor" runat="server" Text="" /&gt;
                                      &lt;asp:FilteredTextBoxExtender ID="txbValor_FilteredTextBoxExtender" 
                                          runat="server" FilterType="Numbers" TargetControlID="txbValor"&gt;
                                      &lt;/asp:FilteredTextBoxExtender&gt;
                                  &lt;/FooterTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                          &lt;/Columns&gt;
                      &lt;/asp:GridView&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;
  
              &lt;asp:UpdateProgress ID="uprgDocumentos" runat="server" 
                  AssociatedUpdatePanelID="upDocumentos" DisplayAfter="2000"&gt;
                  &lt;ProgressTemplate&gt;Loading...&lt;/ProgressTemplate&gt;
              &lt;/asp:UpdateProgress&gt;
              &lt;asp:UpdatePanel ID="upDocumentos" runat="server" UpdateMode="Conditional"&gt;
                  &lt;ContentTemplate&gt;
                      &lt;div ID="dTabelaDocumentosHeader" class="PVPortletHeader"&gt;
                          &lt;div ID="dTabelaDocumentosOpcoes" class="PVPortletHeaderOpcoes"&gt;
                              &lt;asp:Label ID="lDocInicio" runat="server" Text="Inicio" style="float:left;"&gt;&lt;/asp:Label&gt;
                              &lt;asp:TextBox ID="txbInicio" runat="server" style="float:left;"&gt;&lt;/asp:TextBox&gt;
                              &lt;asp:CalendarExtender ID="txbInicio_CalendarExtender" runat="server" Enabled="True" Format="MM-yyyy" TargetControlID="txbInicio"&gt;
                              &lt;/asp:CalendarExtender&gt;
                              &lt;asp:Label ID="lDocFim" runat="server" Text="Fim" style="float:left;"&gt;&lt;/asp:Label&gt;
                              &lt;asp:TextBox ID="txbFim" runat="server" style="float:left;"&gt;&lt;/asp:TextBox&gt;
                              &lt;asp:CalendarExtender ID="txbFim_CalendarExtender" runat="server" Enabled="True" Format="MM-yyyy" TargetControlID="txbFim"&gt;
                              &lt;/asp:CalendarExtender&gt;
                              &lt;asp:Button ID="btnDocFiltro" runat="server" Text="Pesquisar" style="float:left;" OnClick="obterDocumento_OnSeacrh"/&gt;
                          &lt;/div&gt;
                          &lt;b&gt;Documentos Faturação&lt;/b&gt;
                          &lt;asp:Button ID="btnNovoDocumento" runat="server" OnClientClick="abrirDocumento(0);" Text="Novo" style="float:right;"/&gt;
                      &lt;/div&gt;
                      &lt;asp:Panel ID="pgvDocumentosEmpty" runat="server" Visible="false"&gt;
                          &lt;table class="PVPortlet"&gt;
                              &lt;tbody&gt;
                                  &lt;tr&gt;
                                      &lt;th&gt;&lt;/th&gt;
                                      &lt;th&gt;ID&lt;/th&gt;
                                      &lt;th&gt;Fatura&lt;/th&gt;
                                      &lt;th&gt;Enviado&lt;/th&gt;
                                      &lt;th&gt;Estado&lt;/th&gt;
                                      &lt;th&gt;Tipo&lt;/th&gt;
                                      &lt;th&gt;Descrição&lt;/th&gt;
                                      &lt;th&gt;Valor&lt;/th&gt;
                                  &lt;/tr&gt;
                                  &lt;tr&gt;
                                      &lt;td colspan="8"&gt;Sem dados...&lt;/td&gt;
                                  &lt;/tr&gt;
                              &lt;/tbody&gt;
                          &lt;/table&gt;
                      &lt;/asp:Panel&gt;
                      &lt;asp:GridView ID="gvDocumentos" runat="server" AutoGenerateColumns="false" AutoGenerateDeleteButton="false" AutoGenerateEditButton="false" AutoGenerateSelectButton="false" CssClass="PVPortlet"&gt;
                          &lt;Columns&gt;
                              &lt;asp:TemplateField&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:LinkButton Text="Abrir" runat="server" ID="lbtnAbrirDoc" OnClientClick='&lt;%#"abrirDocumento(" + Eval("ID") + ");"%&gt;' /&gt;
                                  &lt;/ItemTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                              &lt;asp:BoundField DataField="ID" HeaderText="ID" HtmlEncode="false" /&gt;
                              &lt;asp:BoundField DataField="NFATURA" HeaderText="Fatura" HtmlEncode="false" /&gt;
                              &lt;asp:BoundField DataField="EnviadoA" DataFormatString="{0:dd-MM-yyyy}" HeaderText="Enviado" HtmlEncode="false" /&gt;
                              &lt;utl:CompositeBoundField DataField="Estado.Descricao" HeaderText="Estado" HtmlEncode="false" /&gt;
                              &lt;utl:CompositeBoundField DataField="Tipo.Descricao" HeaderText="Tipo" HtmlEncode="false" /&gt;
                              &lt;asp:TemplateField HeaderText="Descrição"&gt;
                                  &lt;ItemTemplate&gt;
                                      &lt;asp:Label ID="lCabecalho" runat="server" Text='&lt;%#Eval("Cabecalho").ToString().Cut(30,true)+"-"+Eval("Periodo")%&gt;' /&gt;
                                  &lt;/ItemTemplate&gt;
                              &lt;/asp:TemplateField&gt;
                              &lt;asp:BoundField DataField="Valor" HeaderText="Valor" HtmlEncode="false" /&gt;
                          &lt;/Columns&gt;
                      &lt;/asp:GridView&gt;
                  &lt;/ContentTemplate&gt;
              &lt;/asp:UpdatePanel&gt;    
          &lt;/asp:Panel&gt;
          &lt;/ContentTemplate&gt;
          &lt;/asp:UpdatePanel&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Server SIde</p>
  
  <pre><code> protected void Page_Load(object sender, EventArgs e)
              {
                  userName = HttpContext.Current.User.Identity.Name.ToString().ToUpper();
                  sessionID = Session.SessionID;
  
                  if (!IsPostBack)
                  {
                      Session["USER_" + sessionID] = userName;
                      Session["TAREFAS_INV_" + sessionID] = null;
                      Session["PARCELAS_"+sessionID] = null;
                      Session["DOCUMENTOS_"+sessionID] = null;
  
                      carregaDadosFiltros();
  
                      string idPrj = null;
                      obtemParametrosEntrada(ref idPrj);
  
                      pgvDocumentosEmpty.Visible = true;
                      pgvParcelasEmpty.Visible = true;
                      pgvTarefasEmpty.Visible = true;
                      gvDocumentos.Visible = false;
                      gvParcelas.Visible = false;
                      gvTarefas.Visible = false;
  
                      if (!string.IsNullOrEmpty(idPrj))
                      {
                          bool filtra = true;
                          if (cblProjeto.Items.FindByValue(idPrj) != null)
                          {
                              cblProjeto.SelectedValue = idPrj;
                          }
                          else
                          {
                              string nome = InvDataAccess.obterNomeProjeto(idPrj);
                              if(!string.IsNullOrEmpty(nome))
                              {
                                  ListItem prj = new ListItem(nome, idPrj, true);
                                  cblProjeto.Items.Add(prj);
                                  cblProjeto.SelectedValue = prj.Value;
                              }
                              else
                                  filtra = false;
                          }
                          cblCliente.SelectedValue = "all";
                          cblPedido.SelectedValue = "all";
                          if(filtra) btnFiltra_Click(null, null);
                      }
                  }
                  else
                  {
                      userName = Session["USER_" + sessionID] as string;
                      DateTime inicio = DateTime.MinValue, fim = DateTime.MaxValue;
                      if (!DateTime.TryParseExact(txbInicio.Text, txbInicio_CalendarExtender.Format, null, System.Globalization.DateTimeStyles.None, out inicio))
                          txbInicio_CalendarExtender.SelectedDate = DateTime.MinValue;
                      if (!DateTime.TryParseExact(txbFim.Text, txbFim_CalendarExtender.Format, null, System.Globalization.DateTimeStyles.None, out fim))
                          txbFim_CalendarExtender.SelectedDate = DateTime.MaxValue;
                      if (Session["TAREFAS_INV_"+sessionID] != null)
                          tarefas = (Dictionary&lt;int, InvTarefas&gt;)Session["TAREFAS_INV_"+sessionID];
  
                      if (Session["PARCELAS_"+sessionID] != null)
                      {
                          parcelas = (Dictionary&lt;int, InvParcelaTarefa&gt;)Session["PARCELAS_"+sessionID];
                          gvParcelas.DataSource = parcelas.Values.ToList();
                      }
  
                      if (Session["DOCUMENTOS_"+sessionID] != null)
                      {
                          documentos = (Dictionary&lt;int, InvDocumento&gt;)Session["DOCUMENTOS_"+sessionID];
                          gvDocumentos.DataSource = documentos.Values.ToList();
                      }
  
                  }
              }
  
  protected void btnFiltra_Click(object sender, EventArgs e)
          {
              tarefas.Clear();
              List&lt;string&gt; idCliente, idPedido, idProjeto;
              DateTime inicio, fim;
              idCliente = cblCliente.Items.Cast&lt;ListItem&gt;().Where(i =&gt; i.Selected).Select(i =&gt; i.Value).ToList();
              idPedido = cblPedido.Items.Cast&lt;ListItem&gt;().Where(i =&gt; i.Selected).Select(i =&gt; i.Value).ToList();
              idProjeto = cblProjeto.Items.Cast&lt;ListItem&gt;().Where(i =&gt; i.Selected).Select(i =&gt; i.Value).ToList();
              inicio = DateTime.MinValue;
              fim = DateTime.MaxValue;
              List&lt;InvTarefas&gt; tars = InvTarefas.getInvTarefas(new List&lt;string&gt;{"all"}, idCliente, idPedido, idProjeto, inicio, fim);
              if (tars != null &amp;&amp; tars.Count &gt; 0)
              {
                  foreach (InvTarefas tar in tars)
                  {
                      tarefas.Add(tar.ID, tar);
                  }
                  this.Session["TAREFAS_INV_"+sessionID] = tarefas;
                  gvTarefas.DataSource = tarefas.Values.ToList();
                  gvTarefas.DataBind();
                  pgvTarefasEmpty.Visible = false;
                  gvTarefas.Visible = true;
              }
              else
              {
                  this.Session["TAREFAS_INV_"+sessionID] = null;
  
                  pgvTarefasEmpty.Visible = true;
                  gvTarefas.Visible = false;
              }
          }
  </code></pre>