locked
Trace shows extra Literalcontrols not in source RRS feed

  • Question

  • User602684460 posted

    With something I'm doing, I had enabled trace and found in the Control List tree that there are a whole bunch of, what appear to be, separating LiteralControls that are not even rendered in the actual page.

    I looked at the value of them as they contain bytes which are CR, LF and a bunch of spaces (asc(22)).

    Can anyone explain their existence in the rendering process and what is different about them that prevent them from being rendered?

    Thanks,
    Nathan

    Thursday, December 28, 2006 12:16 PM

All replies

  • User602684460 posted

    Ok, I'm thinking those literals are actually rendered and in the source, though they do not have any tags and thus no clientid.

    It's just writing a crlf and a tab-effect to make the source readable. That's my guess.

    Nathan

    Friday, December 29, 2006 10:39 PM
  • User1347187933 posted
    On an ASP.NET page, when controls are added declaratively between the opening and closing tags of a server control, ASP.NET automatically adds the controls to the containing server control's ControlCollection. Any HTML tags or text strings that are not processed on the server are treated as LiteralControl objects. These are added to the collection like other server controls.
    Wednesday, January 3, 2007 4:04 AM
  • User602684460 posted

    Do you think there is an easy way to identify what controls being rendered contain a client id at the page level?

    I'm thinking it would only be seen at the control's rendering level.

    Nathan

    Wednesday, January 3, 2007 4:14 AM
  • User1347187933 posted

    Hi,

    Yes. it is better to turn ASP.NET tracing off first since it will geneartes two much HTML code.

    1. I create a simple form(or empty), using browser to get the resulted HTML code.

    2. Get the new version of html code after add following to code behind.

        protected void Page_Load(object sender, EventArgs e)
        {
            foreach (Control ctl in Controls)
            {
                if (ctl is System.Web.UI.LiteralControl)
                    ((System.Web.UI.LiteralControl)ctl).Text = "Hello";
            }
        }

    it will change all of the LiteralControl Text property to "Hello";

    So then these LiteralControl are replace with "Hello" in HTML source code.

     

    Compare the two version of HTML source, then you can get the ideal what those Literal Controls really are!

     

    Thursday, January 4, 2007 2:36 AM