[asp.net]problem with refreshing the updatepanel from server code

LilPitbull_

New Member
In my app I have a simple upload with jquery and custom http handler binded to button and an update panel to show the uploaded file name:\[code\]<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:Button ID="btnUploadFile" runat="server" Text="Button" /> <%= System.DateTime.Now %> <input id="File1" type="file" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional"> <ContentTemplate> <br /> <br /> <%= System.DateTime.Now %> <asp:Label ID="Label1" runat="server" Text="" ViewStateMode="Disabled"></asp:Label> </ContentTemplate> </asp:UpdatePanel></asp:Content>$(document).ready(function (){ $(function () { $('#file_upload').fileUpload({ url: '../UploadHandler.ashx', method: 'POST', onLoadAll: function (list) { // __doPostBack('MainContent_UpdatePanel1', ''); } }); }); $('#File1').hide(); $('#MainContent_btnUploadFile').click(function () { $('#File1').click(); return false; });});\[/code\]The handler looks that:\[code\]public void ProcessRequest(HttpContext context) { HttpPostedFile uploadedfile = context.Request.Files[0]; string fileName = uploadedfile.FileName; IMainFormViewPresenter presenter = Bootstrapper.ServiceLocator.GetService<IMainFormViewPresenter>(); //do sth.. presenter.SetFileInfo(fileName); presenter.RefreshUpdatePanel(); }\[/code\]and in the view\[code\]public void RefreshUpdatePanel() { // UpdatePanel1.Update(); }public void SetFileInfo(string fileName) { Label1.Text = fileName; }\[/code\]The problem is that, the UpdatePanel1.Update() in the server code doesn't work. Sometimes I get exception: The Update method can only be called on UpdatePanel with ID 'UpdatePanel1' before Render.I can't find out what is going on. The update panel refreshed from javascript work ok, but I'm curious why on the server is problem.Full solution I put here https://dl-web.dropbox.com/get/Public/WebApplication1.rar?w=ea9959b6
 
Top