Wednesday 15 May 2013

How to run a c# function on page load from jQuery $( document ).ready() -


I am trying to play with Ajax, so I have made the following function.

  Secure Zero Button 1_Click (Object Sender, EventArgs E) {Label1.Text = "Refresh on" + Date Time.Now ToString (); } & Lt; Asp: ScriptManager id = "ScriptManager1" runat = "server" & gt; & Lt; / ASP: ScriptManager & gt; & Lt; Asp: UpdatePanel ID = "Update Panel 1" Runat = "Server" & gt; & Lt; ContentTemplate & gt; & Lt; Fieldset & gt; & Lt; Story & gt; UpdatePanel & lt; / Narrative & gt; & Lt; ASP: labeled id = "label 1" runat = "server" text = "panel created". & Gt; & Lt; / Asp: label & gt; & Lt; Br / & gt; & Lt; ASP: Button ID = "Button 1" Runat = "Server" OnClick = "Button 1_Click" Text = "Button" /> & Lt; / Fieldset & gt; & Lt; / ContentTemplate & gt; & Lt; / ASP: UpdatePanel & gt;  

So the examples given above from Microsoft now work perfectly for me what I want to do here button1_ click on the function $ (document) ) Is run.ready ()

This is not correct, doPostBack method is an endless Loop will be the reason. Document.Ready -> doPostBack -> Documents .ready -> doPostBack etc.

You can do this

  $ (document) .ready (function () {__do ​​postback ("button1", tap);});  

No comments:

Post a Comment