Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Method not firing

Method not firing

Scheduled Pinned Locked Moved ASP.NET
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    Rick van Woudenberg
    wrote on last edited by
    #1

    Dear all, I use the code below for firing a method, however .. it's not firing. I use the same piece of code (different class though) a little further in my application and it's working fine.

    protected void Page_Load(object sender, EventArgs e)
    {
    Control ce = LoadControl("TimeEntry.ascx");
    pnlProjects.Controls.Add(ce);

            foreach(Control ctl in pnlProjects.Controls)
                if (ctl.GetType() == typeof(TimeEntry))
                {
                    TimeEntry te = (TimeEntry)ctl;
                    te.LoadControls();
                }
        }
    

    I don't want to put

    LoadControls();

    in my Page_Load of TimeEntry.ascx because it's posting back when I navigate away from the page and thus firing the method again. Can any tell me what I am doing wrong. Kind regards,

    P 1 Reply Last reply
    0
    • R Rick van Woudenberg

      Dear all, I use the code below for firing a method, however .. it's not firing. I use the same piece of code (different class though) a little further in my application and it's working fine.

      protected void Page_Load(object sender, EventArgs e)
      {
      Control ce = LoadControl("TimeEntry.ascx");
      pnlProjects.Controls.Add(ce);

              foreach(Control ctl in pnlProjects.Controls)
                  if (ctl.GetType() == typeof(TimeEntry))
                  {
                      TimeEntry te = (TimeEntry)ctl;
                      te.LoadControls();
                  }
          }
      

      I don't want to put

      LoadControls();

      in my Page_Load of TimeEntry.ascx because it's posting back when I navigate away from the page and thus firing the method again. Can any tell me what I am doing wrong. Kind regards,

      P Offline
      P Offline
      Pravin Patil Mumbai
      wrote on last edited by
      #2

      You can put the LoadControls in Page_Load but with below condition :

      If(!IsPostback)
      LoadControls()

      This will cause the LoadControls to call only at the first loading of the page and not everytime postback occurs. IsPostBack property is used to check whether the page is getting loaded first time of the postback caused by any control on the page. Hope this helps. All the best.

      I quit being afraid when my first venture failed and the sky didn't fall down.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups