Dynamic Controls: Sys.ArgumentException: Value must not be null for Controls and Behaviors

3 posts, 1 answers
  1. Greg
    Greg avatar
    6 posts
    Member since:
    Dec 2007

    Posted 15 Sep 2008 Link to this post

    I'm trying to build a Multi-View with some "Next" and "Previous" buttons in the CreateChildControls for a page (to later put into a SharePoint webpart) and while everything loads and seems to work ok, I get a javascript error:

    "Sys.ArgumentException: Value must not be null for Controls and Behaviors"

    I found some posts for ASP.NET AJAX in general that pointed at problems with the visibility of controls, but no matter what I did, I can't get rid of that JavaScript Error.  Has anybody run into this and know a way I can get rid of that error?

    Code is below the sig...

    Thanks in advanced,
    Greg Andora
    Littler Mendelson
    Enterprise Applications & Development Team
    Lead Applications Developer
    http://www.linkedin.com/in/gregandora

    1         RadMultiPage mpage;  
    2         RadPageView pv;  
    3         Button btnPrevious;  
    4         Button btnNext;  
    5  
    6         protected override void CreateChildControls()  
    7         {  
    8             base.CreateChildControls();  
    9  
    10             RadAjaxPanel ajaxPanel = new RadAjaxPanel();  
    11  
    12             mpage = new RadMultiPage();  
    13  
    14             HtmlGenericControl topDiv = new HtmlGenericControl("div");  
    15             topDiv.ID = "topdiv";  
    16  
    17             btnPrevious = new Button();  
    18             btnPrevious.ID = "btnPrevious";  
    19             btnPrevious.Text = "Previous ";  
    20             btnPrevious.Click += new EventHandler(btnPrevious_Click);  
    21             btnPrevious.Enabled = false;  
    22             topDiv.Controls.Add(btnPrevious);  
    23  
    24             btnNext = new Button();  
    25             btnNext.ID = "btnNext";  
    26             btnNext.Text = "Next ";  
    27             btnNext.Click += new EventHandler(btnNext_Click);  
    28             topDiv.Controls.Add(btnNext);  
    29  
    30             for (int i = 0; i < 3; i++)  
    31             {  
    32                 HtmlGenericControl bottomDiv = new HtmlGenericControl("div");  
    33                 bottomDiv.ID = "bottomDiv" + i.ToString();  
    34                 pv = new RadPageView();  
    35                 Literal Lit = new Literal();  
    36                 Lit.Text = "Page" + i.ToString();  
    37  
    38                 bottomDiv.Controls.Add(Lit);  
    39                 pv.Controls.Add(bottomDiv);  
    40                 mpage.PageViews.Add(pv);  
    41  
    42             }  
    43  
    44             mpage.SelectedIndex = 0;  
    45             ajaxPanel.Controls.Add(topDiv);  
    46             ajaxPanel.Controls.Add(mpage);  
    47             form1.Controls.Add(ajaxPanel);  
    48         }  
    49  
    50         void btnNext_Click(object sender, EventArgs e)  
    51         {  
    52             mpage.SelectedIndex++;  
    53  
    54             if (mpage.SelectedIndex == mpage.PageViews.Count - 1)  
    55             { btnNext.Enabled = false; }  
    56             else   
    57             { btnNext.Enabled = true; }  
    58  
    59             if (mpage.SelectedIndex == 0)   
    60             { btnPrevious.Enabled = false; }  
    61             else   
    62             {btnPrevious.Enabled = true;}  
    63         }  
    64  
    65         void btnPrevious_Click(object sender, EventArgs e)  
    66         {  
    67             mpage.SelectedIndex--;  
    68  
    69             if (mpage.SelectedIndex == mpage.PageViews.Count - 1)  
    70             { btnNext.Enabled = false; }  
    71             else { btnNext.Enabled = true; }  
    72             if (mpage.SelectedIndex == 0)   
    73             { btnPrevious.Enabled = false; }  
    74             else   
    75             { btnPrevious.Enabled = true; }  
    76  
    77         }  
    78  
    79     }  
    80  

     

  2. Answer
    Atanas Korchev
    Admin
    Atanas Korchev avatar
    8462 posts

    Posted 16 Sep 2008 Link to this post

    Hello Greg,

    You can try assigning an ID for the tabstrip and multipage.

    Regards,
    Albert
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Greg
    Greg avatar
    6 posts
    Member since:
    Dec 2007

    Posted 17 Sep 2008 Link to this post

    That did it, thanks very much!!

    Thanks,
    Greg Andora
    Littler Mendelson
    Enterprise Applications & Development Team
    Lead Applications Developer
    http://www.linkedin.com/in/gregandora
Back to Top