Reputation: 2186
I am trying to play with Ajax a bit so i have created the following function.
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Refreshed at " + DateTime.Now.ToString();
}
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<fieldset>
<legend>UpdatePanel</legend>
<asp:Label ID="Label1" runat="server" Text="Panel created."></asp:Label><br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</fieldset>
</ContentTemplate>
</asp:UpdatePanel>
So this above example from Microsoft. Now this works perfectly for me. what i want to do here is run the Button1_Click
function on $(document ).ready()
Upvotes: 0
Views: 417
Reputation: 359
This is not the right thing to do, the doPostBack method will cause an endless loop. document.Ready -> doPostBack -> Document.ready -> doPostBack. Etc..
You can do this
$(document).ready(function() {
__doPostBack("Button1", null);
});
Upvotes: 1