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. Confused of dynamically added controls on AJAX page

Confused of dynamically added controls on AJAX page

Scheduled Pinned Locked Moved ASP.NET
3 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.
  • S Offline
    S Offline
    Spoks_ST
    wrote on last edited by
    #1

    Sorry for bad English, as it`s only 3rd language... In every post regarding adding controls, it is written that I should add them OnInit event, however at that time, I do no know, witch control I must add. :( If I add them on Button click, all shows as planed, but if I add them at ScriptManager OnNavigate event, they do not show up :(

    It`s nothing to wory before something happen and when it happents it`s alredy to late to wory! :)

    A 1 Reply Last reply
    0
    • S Spoks_ST

      Sorry for bad English, as it`s only 3rd language... In every post regarding adding controls, it is written that I should add them OnInit event, however at that time, I do no know, witch control I must add. :( If I add them on Button click, all shows as planed, but if I add them at ScriptManager OnNavigate event, they do not show up :(

      It`s nothing to wory before something happen and when it happents it`s alredy to late to wory! :)

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      Here is some tips for adding dynamic control. . You have to create all the control before Page_Load(), Preferably on Page_PreInit(). Because if we create any dynamic control after Page_load(), The control will not maintain, ViewState and Postback data. Because, View State and Post back Load just before Page_load. So, if we create any control after postback, it will not able to get the view state and postback data. Let me know if you have any problem. Hope this information will help you :-D

      Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

      S 1 Reply Last reply
      0
      • A Abhijit Jana

        Here is some tips for adding dynamic control. . You have to create all the control before Page_Load(), Preferably on Page_PreInit(). Because if we create any dynamic control after Page_load(), The control will not maintain, ViewState and Postback data. Because, View State and Post back Load just before Page_load. So, if we create any control after postback, it will not able to get the view state and postback data. Let me know if you have any problem. Hope this information will help you :-D

        Abhijit Jana | Codeproject MVP Web Site : abhijitjana.net Don't forget to click "Good Answer" on the post(s) that helped you. View My Latest Article

        S Offline
        S Offline
        Spoks_ST
        wrote on last edited by
        #3

        I know that :( But I do not care about viewstate or Postback, all controls that should talk to server are in main page, not in update panel, only thing that do not work as wanted is ScriptManagers OnNavigate event. It fires too late. I need that event to handle f5, back and forward. If controls are added as fallows: protected void mi1_click(object sender, EventArgs e) { test(); } all is ok :( But in this case: public void OnNavigateHistory(object sender, HistoryEventArgs e) { test(); } it will not work :( void test() { //This line works fine in both cases. It sets couple of properties, as label texts and session variables. set_title("Test title"); //Instead of button I need my usercontrol, but even button will not show up. Button btn = new Button(); btn.Text = "I bitīt matos!!!!!!!!!!!"; PHolder.Controls.Clear(); PHolder.Controls.Add(btn); sm.AddHistoryPoint("aa", "bb"); }

        It`s nothing to wory before something happen and when it happents it`s alredy to late to wory! :)

        modified on Friday, July 31, 2009 3:15 PM

        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