2016-06-10 3 views
0

Je travaille sur une application Web ASP.NET. Où j'ai ajouté un contrôleur ascx avec un asp:updatepanel à l'intérieur. Le problème est maintenant que lorsque vous essayez de faire une mise à jour donne l'erreur suivante:MicrosoftAjax.js - POST 500 (erreur de serveur interne) sur PostBack


MicrosoftAjax.js:5 POST http://localhost:49735/ 500 (Internal Server Error) 
    executeRequest  @ MicrosoftAjax.js:5 
    executeRequest  @ MicrosoftAjax.js:5 
    invoke    @ MicrosoftAjax.js:5 
    _onFormSubmit  @ MicrosoftAjaxWebForms.js:5 
    (anonymous function) @ MicrosoftAjax.js:5 
    b     @ MicrosoftAjax.js:5 


mon dossier ascx ressemble à ceci:

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SearchResults.ascx.cs" Inherits="CarParts24.Controls.Search.Results.SearchResults" %> 

<asp:UpdatePanel ID="UpdPnlSearchResults" runat="server"> 
<ContentTemplate> 
    <span id="search-result-json" class="hidden"> 
     <asp:HiddenField ID="hiddenSearchResults" runat="server" /> 
    </span> 

    <%--<asp:Panel ID="PanelResult" runat="server">--%> 

      <%-- Some ordinary HTML code --%> 

    <%--</asp:Panel>--%> 
</ContentTemplate> 
</asp:UpdatePanel> 


et codebehind:

using Newtonsoft.Json; 
using System; 
using System.Collections.Generic; 
using System.Data; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 

namespace CarParts24.Controls.Search.Results 
{ 
public partial class SearchResults : System.Web.UI.UserControl 
{ 
    protected void Page_Load(object sender, EventArgs e) 
    { 
     PanelResult.Visible = false; 
    } 

    public void ShowResults(DataTable datatable) 
    { 
     hiddenSearchResults.Value = JsonConvert.SerializeObject(datatable); 
     PanelResult.Visible = true; 
    } 
} 
} 

Répondre

0

J'ai trouvé le problème, cela était dû à la <asp:HiddenField ID="hiddenSearchResults" runat="server" /> faire une publication lors de l'actualisation. le changer en <asp:Literal ID="hiddenSearchResults" runat="server" /> a résolu le problème