function call after page load

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Anjana Bhat
    New Member
    • Oct 2008
    • 3

    function call after page load

    Hi,
    im using asp.net with c#
    i want to call a server side function immediately after the page loads.for eg. it should be like this
    Code:
    public partial class test : System.Web.UI.Page
    {
       protected void Page_Load(object sender, EventArgs e)
        {
            ....
        }
        call the function
        function()
        {
           ....
        }
    }
    .Is this possible?
    Last edited by Curtis Rutland; Oct 30 '08, 03:34 PM. Reason: added [code] tags
  • Plater
    Recognized Expert Expert
    • Apr 2007
    • 7872

    #2
    Call your function in the page load eventhandler there?

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Do you want to call the function right after the page loads in the browser (client side) or right after the page loads on the server (server side)?

      It seems to me that you want to call the function IN your PageLoad method (the last line in the method).




      If you want to post back to the server right after the page loads in the browser...You could look into implementing the IPostBackDataHa ndler Interface for the ASP.NET page.

      Then Override the OnInit method and specify that Page is registered requires postback....
      eg
      [code=vbnet]
      Protected Overrides Sub OnInit(ByVal e As EventArgs)
      InitializeCompo nent()
      MyBase.OnInit(e )
      If Not Page Is Nothing Then
      Page.RegisterRe quiresPostBack( Me)
      End If

      End Sub[/code]
      You'll have to specify exactly what should be done when the page posts back in the code that you need to write in order to implement the IPostBackDataHa ndler interface.


      -Frinny

      Comment

      • Curtis Rutland
        Recognized Expert Specialist
        • Apr 2008
        • 3264

        #4
        Please enclose your posted code in [code] tags (See How to Ask a Question).

        This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

        Please use [code] tags in future.

        MODERATOR

        Comment

        Working...