Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8198075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T05:52:29+00:00 2026-06-07T05:52:29+00:00

I add some div into a panel on server side, when the page is

  • 0

I add some div into a panel on server side, when the page is generated, and I add a ID for each one :

HtmlGenericControl divContainerInside = new HtmlGenericControl("div");
divContainerInside.ID = "inside_" + m_oIDCategoria + "_" + numero;

than, on postback (after re-creating them), I cycle them :

foreach (HtmlGenericControl divInside in myPanel.Controls.OfType<HtmlGenericControl>())
{
    Response.Write(divInside.ID);
}

all is ok! But, if I remove that divContainerInside.ID when I generate it, I get a NullException cycling them. Why?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T05:52:30+00:00Added an answer on June 7, 2026 at 5:52 am

    I guess you get NullException when you try to read the ID, which you haven’t set.

    If you change your code like this, you’ll get the value:

    foreach (HtmlGenericControl divInside in myPanel.Controls.OfType<HtmlGenericControl>())
    {
        Response.Write(divInside.ClientID);
    }
    

    PS: I don’t know if you have got this line of code:

    myPanel.Controls.Add(divContainerInside);
    

    If you want to find out more about web controls you can read this article and this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i need to add some text DIV's on each slide of a Nivoslider. I
I'm trying to add some styles into a page using javascript var style =
Adding new html string into the page: document.getElementById('container').innerHTML = '<div id=child></div>'; Is there an
I had to maunally add some html within the sidebar div of html, but
Im trying to add a div tag dynamically with some data attributes but the
When I add event handler to a some elements using query: $('div').mouseover(function () {
TLDR I want to add some dynamic content into an Ext-JS window / popup.
I would like to add some CSS fixed size blocks inline into a text
The following markup will have some extra elements injected into it (i.e.: a div
I've got a list of 10-20 objects on each page creating these forms: <div

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.