Placing control tag text in a multiline TextBox

Discussion in 'ASP .Net' started by Nathan Sokalski, Jan 3, 2008.

  1. I have a multiline TextBox that I want to display the text used to create a
    control in an apsx file. I want each of these to be on a separate line in
    the TextBox. The only way I know of to place things on separate lines in a
    TextBox without doing it programmatically is the following:

    <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine">
    Line 1
    Line 2
    Line 3
    </asp:TextBox>

    However, if I do something like the following:

    <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine">
    <NJS:MyCustomControl ID="MyCtrl1" runat="server"/>
    <NJS:MyCustomControl ID="MyCtrl2" runat="server"/>
    <NJS:MyCustomControl ID="MyCtrl2" runat="server"/>
    </asp:TextBox>

    I receive a Parser Error that says:

    Parser Error Message: The 'Text' property of 'asp:TextBox' does not allow
    child objects.

    Is there any way to avoid this problem without adding the text
    programmatically? Thanks.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/
     
    Nathan Sokalski, Jan 3, 2008
    #1
    1. Advertising

  2. Try something like
    &lt;NJS:MyCustomControl ID="MyCtrl1" runat="server"/&gt;

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Nathan Sokalski" <> wrote in message
    news:...
    >I have a multiline TextBox that I want to display the text used to create a
    >control in an apsx file. I want each of these to be on a separate line in
    >the TextBox. The only way I know of to place things on separate lines in a
    >TextBox without doing it programmatically is the following:
    >
    > <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine">
    > Line 1
    > Line 2
    > Line 3
    > </asp:TextBox>
    >
    > However, if I do something like the following:
    >
    > <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine">
    > <NJS:MyCustomControl ID="MyCtrl1" runat="server"/>
    > <NJS:MyCustomControl ID="MyCtrl2" runat="server"/>
    > <NJS:MyCustomControl ID="MyCtrl2" runat="server"/>
    > </asp:TextBox>
    >
    > I receive a Parser Error that says:
    >
    > Parser Error Message: The 'Text' property of 'asp:TextBox' does not allow
    > child objects.
    >
    > Is there any way to avoid this problem without adding the text
    > programmatically? Thanks.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
     
    Eliyahu Goldin, Jan 3, 2008
    #2
    1. Advertising

  3. That was not my real concern here, my problem was that I cannot and line
    breaks. Because the text is being placed inside a TextBox, the br tag will
    not work. For the moment, I am simply adding the text in the Init event of
    the Page, but that requires me to make sure all the "'s are added correctly,
    which is a pain to do. Any ideas?
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Eliyahu Goldin" <> wrote in
    message news:...
    > Try something like
    > &lt;NJS:MyCustomControl ID="MyCtrl1" runat="server"/&gt;
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Nathan Sokalski" <> wrote in message
    > news:...
    >>I have a multiline TextBox that I want to display the text used to create
    >>a control in an apsx file. I want each of these to be on a separate line
    >>in the TextBox. The only way I know of to place things on separate lines
    >>in a TextBox without doing it programmatically is the following:
    >>
    >> <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine">
    >> Line 1
    >> Line 2
    >> Line 3
    >> </asp:TextBox>
    >>
    >> However, if I do something like the following:
    >>
    >> <asp:TextBox ID="txtMultiLine" runat="server" TextMode="MultiLine">
    >> <NJS:MyCustomControl ID="MyCtrl1" runat="server"/>
    >> <NJS:MyCustomControl ID="MyCtrl2" runat="server"/>
    >> <NJS:MyCustomControl ID="MyCtrl2" runat="server"/>
    >> </asp:TextBox>
    >>
    >> I receive a Parser Error that says:
    >>
    >> Parser Error Message: The 'Text' property of 'asp:TextBox' does not allow
    >> child objects.
    >>
    >> Is there any way to avoid this problem without adding the text
    >> programmatically? Thanks.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>

    >
    >
     
    Nathan Sokalski, Jan 3, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Simon Middlemiss
    Replies:
    2
    Views:
    5,268
    Jacob Yang [MSFT]
    Nov 10, 2003
  2. Stu
    Replies:
    4
    Views:
    499
  3. shruds
    Replies:
    1
    Views:
    945
    John C. Bollinger
    Jan 27, 2006
  4. Nathan Sokalski

    Placing control tag text in a multiline TextBox

    Nathan Sokalski, Jan 3, 2008, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    229
    Nathan Sokalski
    Jan 3, 2008
  5. dale zhang
    Replies:
    8
    Views:
    457
    Tintin
    Nov 30, 2004
Loading...

Share This Page