How to write a control that doesn't require a closing tag

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default How to write a control that doesn't require a closing tag

    Hi all,

    I've built a custom control that won't contain any inner content. If I
    derive the control from Control, then the VS editor will always add the
    closing tag when I use the control. I can derive from UserControl and
    it doesn't do this, but I'm not sure whether is the best way to do
    this.

    What is the correct way to make a control that is self-closing (i.e.
    doesn't have a closing tag)?

    Thanks,

    Paul

    paul.hester@gmail.com Guest

  2. Similar Questions and Discussions

    1. Refresh tree control without closing? HELP
      I concider myself a Flex professional but this oppertunity is beginning to consume me, please help. <mx:HTTPService id="treeModel"...
    2. How do I get a custom Control Designer to write to the HTML of my control?
      I have created a custom 'Control Designer' that provids a popup dialog for entering more complex properties (such as property builder in the data...
    3. #25782 [Fbk->Opn]: require( 'require.php' ) crashing Apache 1.3.28
      ID: 25782 User updated by: akinder at technology-x dot com Reported By: akinder at technology-x dot com -Status: ...
    4. #25782 [Opn->Fbk]: require( 'require.php' ) crashing Apache 1.3.28
      ID: 25782 Updated by: sniper@php.net Reported By: akinder at technology-x dot com -Status: Open +Status: ...
    5. #25782 [NEW]: require( 'require.php' ) crashing Apache 1.3.28
      From: akinder at technology-x dot com Operating system: Linux RedHat 9 PHP version: 5.0.0b1 (beta1) PHP Bug Type: Apache...
  3. #2

    Default Re: How to write a control that doesn't require a closing tag

    <paul.hester@gmail.com> wrote in message
    news:1158725719.344437.243950@k70g2000cwa.googlegr oups.com...
    > Hi all,
    >
    > I've built a custom control that won't contain any inner content. If I
    > derive the control from Control, then the VS editor will always add the
    > closing tag when I use the control. I can derive from UserControl and
    > it doesn't do this, but I'm not sure whether is the best way to do
    > this.
    >
    > What is the correct way to make a control that is self-closing (i.e.
    > doesn't have a closing tag)?
    May I ask why you want to do this? You will need the closing tag for XHTML
    compliance, or at least the closing slash:

    <my:tag/>

    John


    John Saunders Guest

  4. #3

    Default Re: How to write a control that doesn't require a closing tag

    Hi John,

    I want the closing slash, just not the closing tags. When the designer
    auto-closes tags, it sometimes appends a " />" and for others it'll
    append a "</my:tag>".

    I just wanted to know the correct way to write a control where the form
    designer knows won't accept any inner content.

    Thanks,

    Paul

    John Saunders wrote:
    > <paul.hester@gmail.com> wrote in message
    > news:1158725719.344437.243950@k70g2000cwa.googlegr oups.com...
    > > Hi all,
    > >
    > > I've built a custom control that won't contain any inner content. If I
    > > derive the control from Control, then the VS editor will always add the
    > > closing tag when I use the control. I can derive from UserControl and
    > > it doesn't do this, but I'm not sure whether is the best way to do
    > > this.
    > >
    > > What is the correct way to make a control that is self-closing (i.e.
    > > doesn't have a closing tag)?
    >
    > May I ask why you want to do this? You will need the closing tag for XHTML
    > compliance, or at least the closing slash:
    >
    > <my:tag/>
    >
    > John
    paul.hester@gmail.com Guest

  5. #4

    Default Re: How to write a control that doesn't require a closing tag

    <paul.hester@gmail.com> wrote in message
    news:1158868445.348947.165500@m7g2000cwm.googlegro ups.com...
    > Hi John,
    >
    > I want the closing slash, just not the closing tags. When the designer
    > auto-closes tags, it sometimes appends a " />" and for others it'll
    > append a "</my:tag>".
    >
    > I just wanted to know the correct way to write a control where the form
    > designer knows won't accept any inner content.
    I don't beleive this is possible with .NET 1.1. Maybe in 2.0, but I don't
    know.

    Will your control produce an error if there is inner content? Would inner
    whitespace be ok?

    John


    John Saunders Guest

  6. #5

    Default Re: How to write a control that doesn't require a closing tag

    The control won't throw an error - it just won't display any of the
    inner content. I just wanted to emulate some of the existing server
    control behaviour where it auto-closes with the "/>". I can achieve
    this by deriving the control from UserControl, but I just thought
    there'd be a better way of doing this.

    Paul

    John Saunders wrote:
    > <paul.hester@gmail.com> wrote in message
    > news:1158868445.348947.165500@m7g2000cwm.googlegro ups.com...
    > > Hi John,
    > >
    > > I want the closing slash, just not the closing tags. When the designer
    > > auto-closes tags, it sometimes appends a " />" and for others it'll
    > > append a "</my:tag>".
    > >
    > > I just wanted to know the correct way to write a control where the form
    > > designer knows won't accept any inner content.
    >
    > I don't beleive this is possible with .NET 1.1. Maybe in 2.0, but I don't
    > know.
    >
    > Will your control produce an error if there is inner content? Would inner
    > whitespace be ok?
    >
    > John
    paul.hester@gmail.com Guest

  7. #6

    Default Re: How to write a control that doesn't require a closing tag

    <paul.hester@gmail.com> wrote in message
    news:1158959252.637568.50360@m7g2000cwm.googlegrou ps.com...
    > The control won't throw an error - it just won't display any of the
    > inner content. I just wanted to emulate some of the existing server
    > control behaviour where it auto-closes with the "/>". I can achieve
    > this by deriving the control from UserControl, but I just thought
    > there'd be a better way of doing this.
    Out of curiosity, which controls auto-close like this, other than user
    controls?

    John


    John Saunders Guest

  8. #7

    Default Re: How to write a control that doesn't require a closing tag

    > I want the closing slash, just not the closing tags. When the designer
    > auto-closes tags, it sometimes appends a " />" and for others it'll
    > append a "</my:tag>".
    For your Control, have ToolboxData attribute with appropriate values.

    eg:

    [ToolboxData("{0}:ControlName runat='server />"]
    public class MyCustomControl : Control
    {
    ...
    }


    --
    Happy Hacking,
    Gaurav Vaish | [url]http://www.mastergaurav.com[/url]
    [url]http://www.edujinionline.com[/url]
    [url]http://articles.edujinionline.com/webservices[/url]
    -------------------


    Gaurav Vaish \(www.EduJiniOnline.com\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139