Partial postback with Javascript

Viewed 38705

I couldn't find something similar in SO.

In ASP.NET, is there any way that on cue I can cause a partial postback with Javascript in an UpdatePanel?
I tried __doPostBack() but it does a full postback.
I can trick it with a dummy button and fire click() then handle the partial postback that way, but I want a more graceful way than trickery.

Thanks.

Edit: I found this disturbedbuddha.wordpress.com/2007/11/26/… but I can't get it to work =(
I would love for this method to work; it's perfect for me! So far what I can do using this last method is gain reference to the timer. With the timer initially disabled, starting the timer doesn't seem to cause a postback. However, without Ajax, if I simply have the timer enabled initially, it posts back at intervals just fine; why can't the Ajax call cause it?

3 Answers

The solution that worked for me

ASPX

<script>
  function myfunc(){
    __doPostBack('<%=UpdatePanel2.ClientID%>', "");
  }
</script>

<asp:UpdatePanel ID="UpdatePanel2" runat="server" OnLoad="UpdatePanel1_Load">       
</asp:UpdatePanel>

.cs

protected void UpdatePanel1_Load(object sender, EventArgs e)
{
   if (IsPostBack)
   {
      //your code
   }        
}
Related