title: Refresh user control inside an update panel from javascript
body: <p>I am working on a project where I want to refresh a part of the web page where i have a user control that contain dynamic data.user control will load data from a text file as this text file will update frequently. I need to refresh the user control alone not the whole page using javascript.   I tried the following but it did not worked for me.</p>
  
  <pre><code>&lt;%@ Page Language="C#" %&gt;
  
  &lt;%@ Register src="ucTest.ascx" tagname="ucTest" tagprefix="uc1" %&gt;
  
  &lt;script runat="server"&gt;
  
     void button_Click(object sender, EventArgs e)
     {
           lbltest.Text = "Refreshed by server side event handler at " + DateTime.Now + ".&lt;br&gt;";
     }
  
  &lt;/script&gt;
  
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
  
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
     &lt;title&gt;How to update an UpdatePanel with JavaScript&lt;/title&gt;
  
     &lt;script type="text/javascript"&gt;
     function UpdPanelUpdate()
     {
           __doPostBack("&lt;%= button.ClientID %&gt;","");
     }
     &lt;/script&gt;
  
  &lt;/head&gt;
  &lt;body&gt;
     &lt;form id="form1" runat="server"&gt;
           &lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt;
           &lt;div&gt;
  
  
     &lt;a href="javascript:UpdPanelUpdate()"&gt;Update the Panel&lt;/a&gt;
  
        &lt;asp:Button ID="button" runat="server" OnClick="button_Click" style="display:none;"/&gt;
  
              &lt;asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional"&gt;
                    &lt;ContentTemplate&gt;
                          &lt;uc1:ucTest ID="ucTest1" runat="server" /&gt;
                          &lt;asp:Label ID="lbltest" runat="server"&gt;&lt;/asp:Label&gt;
                    &lt;/ContentTemplate&gt;
                    &lt;Triggers&gt;
                       &lt;asp:AsyncPostBackTrigger ControlID="button" EventName="Click" /&gt;
                    &lt;/Triggers&gt;
              &lt;/asp:UpdatePanel&gt;
           &lt;/div&gt;
     &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>my user control is.</p>
  
  <pre><code>    &lt;%@ Control Language="C#" AutoEventWireup="true" CodeFile="ucTest.ascx.cs" Inherits="ucTest" %&gt;
  &lt;table border="3"&gt;
        &lt;tr&gt;
              &lt;td&gt;
                    &lt;%   Response.WriteFile("TextFile.txt"); %&gt;
              &lt;/td&gt;
        &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p>Here TextFile.txthas some information that will be changed frequently.</p>
  
  <p>any help would be greatly appreciated. </p>