prevent runat="server"

Discussion in 'ASP .Net Web Controls' started by Willy Van den Driessche, Jun 3, 2006.

  1. I have a set of webcontrols that will only run on the server. Is there a
    way I can specify this in my code, so that the designer using my controls
    (he is not using visual studio but Adobe Golive on Mac) doesn't have to
    specify this for each custom control tag ?

    So instead of
    <abc:myControl runat="server" />

    he can just write
    <abc:myControl/>

    thanks in advance
     
    Willy Van den Driessche, Jun 3, 2006
    #1
    1. Advertising

  2. I believe there is (if you look at the ASP:ListItem control you will notice
    that you don't need to specify runat="server" for that). However, I would
    not recommend going to the effort of using it unless it is a control that is
    used ONLY between the opening/closing tags of one of your other controls.
    This is my recommendation because seeing the runat="server" helps
    distinguish the server controls from the HTML controls, so it is probably
    not worth the trouble and possible risk of extra errors unless the control
    will be used a HUGE number of times on the same page.
    --
    Nathan Sokalski

    http://www.nathansokalski.com/

    "Willy Van den Driessche" <willy.van.den.driessche@gmailDOOTcom> wrote in
    message news:...
    >I have a set of webcontrols that will only run on the server. Is there a
    >way I can specify this in my code, so that the designer using my controls
    >(he is not using visual studio but Adobe Golive on Mac) doesn't have to
    >specify this for each custom control tag ?
    >
    > So instead of
    > <abc:myControl runat="server" />
    >
    > he can just write
    > <abc:myControl/>
    >
    > thanks in advance
    >
     
    Nathan Sokalski, Jun 3, 2006
    #2
    1. Advertising

  3. Thanks for the answer. I have investigated how the ASP:ListItem
    accomplishes this but I have been without luck.

    As for the visibility, using <myPrefix: should be enough to make it stand
    out of the ordinary HTML markup (but that of course is gustibus et
    coloribus).

    "Nathan Sokalski" <> schreef in bericht
    news:...
    >I believe there is (if you look at the ASP:ListItem control you will notice
    >that you don't need to specify runat="server" for that). However, I would
    >not recommend going to the effort of using it unless it is a control that
    >is used ONLY between the opening/closing tags of one of your other
    >controls. This is my recommendation because seeing the runat="server" helps
    >distinguish the server controls from the HTML controls, so it is probably
    >not worth the trouble and possible risk of extra errors unless the control
    >will be used a HUGE number of times on the same page.
    > --
    > Nathan Sokalski
    >
    > http://www.nathansokalski.com/
    >
    > "Willy Van den Driessche" <willy.van.den.driessche@gmailDOOTcom> wrote in
    > message news:...
    >>I have a set of webcontrols that will only run on the server. Is there a
    >>way I can specify this in my code, so that the designer using my controls
    >>(he is not using visual studio but Adobe Golive on Mac) doesn't have to
    >>specify this for each custom control tag ?
    >>
    >> So instead of
    >> <abc:myControl runat="server" />
    >>
    >> he can just write
    >> <abc:myControl/>
    >>
    >> thanks in advance
    >>

    >
    >
     
    Willy Van den Driessche, Jun 3, 2006
    #3
  4. Willy Van den Driessche

    mnichols Guest

    Hello,

    I don't think there is any way that you can easily get away from
    including the runat="server" attribute value pair since it is exactly
    what the server uses to identify sever side nodes.

    The asp:ListItem can probably get away without it since it is a child of
    an asp:DropDownList tag that already has a runat="server
    attribute/value pair. (This would suggest that you could use a <body
    runat="server ....> tag to trigger server side preprocessing to add the
    runat tags where necessary but it would probably be challenging.)

    If you are using XHTML then you probably use xslt preprocessing (with or
    without the <body runat="server ....> attribute). Again that would lead
    to challenges because for some tags, i.e. <input>, it is optional to
    have runat="server" though your practices may allow you to be 100%
    certain of where you want or don't want runat="server" to appear.

    If server-side preprocessing is a realistic option then regular
    expressions may be a path to consider instead of xslt.

    HTH,

    mnichols

    Willy Van den Driessche wrote:
    > Thanks for the answer. I have investigated how the ASP:ListItem
    > accomplishes this but I have been without luck.
    >
    > As for the visibility, using <myPrefix: should be enough to make it stand
    > out of the ordinary HTML markup (but that of course is gustibus et
    > coloribus).
    >
    > "Nathan Sokalski" <> schreef in bericht
    > news:...
    >> I believe there is (if you look at the ASP:ListItem control you will notice
    >> that you don't need to specify runat="server" for that). However, I would
    >> not recommend going to the effort of using it unless it is a control that
    >> is used ONLY between the opening/closing tags of one of your other
    >> controls. This is my recommendation because seeing the runat="server" helps
    >> distinguish the server controls from the HTML controls, so it is probably
    >> not worth the trouble and possible risk of extra errors unless the control
    >> will be used a HUGE number of times on the same page.
    >> --
    >> Nathan Sokalski
    >>
    >> http://www.nathansokalski.com/
    >>
    >> "Willy Van den Driessche" <willy.van.den.driessche@gmailDOOTcom> wrote in
    >> message news:...
    >>> I have a set of webcontrols that will only run on the server. Is there a
    >>> way I can specify this in my code, so that the designer using my controls
    >>> (he is not using visual studio but Adobe Golive on Mac) doesn't have to
    >>> specify this for each custom control tag ?
    >>>
    >>> So instead of
    >>> <abc:myControl runat="server" />
    >>>
    >>> he can just write
    >>> <abc:myControl/>
    >>>
    >>> thanks in advance
    >>>

    >>

    >
    >
     
    mnichols, Jun 3, 2006
    #4
  5. Thank you both for the responses.
    I think the clue is to let the parent object have the runat=server and let
    the child object derive from System.Object instead of one of Web.UI classes.
    The father object is then reponsible for the rendering.

    Thanks,
    Van den Driessche Willy.
    "mnichols" <> schreef in bericht
    news:O%...
    > Hello,
    >
    > I don't think there is any way that you can easily get away from including
    > the runat="server" attribute value pair since it is exactly what the
    > server uses to identify sever side nodes.
    >
    > The asp:ListItem can probably get away without it since it is a child of
    > an asp:DropDownList tag that already has a runat="server attribute/value
    > pair. (This would suggest that you could use a <body runat="server ....>
    > tag to trigger server side preprocessing to add the runat tags where
    > necessary but it would probably be challenging.)
    >
    > If you are using XHTML then you probably use xslt preprocessing (with or
    > without the <body runat="server ....> attribute). Again that would lead to
    > challenges because for some tags, i.e. <input>, it is optional to have
    > runat="server" though your practices may allow you to be 100% certain of
    > where you want or don't want runat="server" to appear.
    >
    > If server-side preprocessing is a realistic option then regular
    > expressions may be a path to consider instead of xslt.
    >
    > HTH,
    >
    > mnichols
    >
    > Willy Van den Driessche wrote:
    >> Thanks for the answer. I have investigated how the ASP:ListItem
    >> accomplishes this but I have been without luck.
    >>
    >> As for the visibility, using <myPrefix: should be enough to make it stand
    >> out of the ordinary HTML markup (but that of course is gustibus et
    >> coloribus).
    >>
    >> "Nathan Sokalski" <> schreef in bericht
    >> news:...
    >>> I believe there is (if you look at the ASP:ListItem control you will
    >>> notice that you don't need to specify runat="server" for that). However,
    >>> I would not recommend going to the effort of using it unless it is a
    >>> control that is used ONLY between the opening/closing tags of one of
    >>> your other controls. This is my recommendation because seeing the
    >>> runat="server" helps distinguish the server controls from the HTML
    >>> controls, so it is probably not worth the trouble and possible risk of
    >>> extra errors unless the control will be used a HUGE number of times on
    >>> the same page.
    >>> --
    >>> Nathan Sokalski
    >>>
    >>> http://www.nathansokalski.com/
    >>>
    >>> "Willy Van den Driessche" <willy.van.den.driessche@gmailDOOTcom> wrote
    >>> in message news:...
    >>>> I have a set of webcontrols that will only run on the server. Is there
    >>>> a way I can specify this in my code, so that the designer using my
    >>>> controls (he is not using visual studio but Adobe Golive on Mac)
    >>>> doesn't have to specify this for each custom control tag ?
    >>>>
    >>>> So instead of
    >>>> <abc:myControl runat="server" />
    >>>>
    >>>> he can just write
    >>>> <abc:myControl/>
    >>>>
    >>>> thanks in advance
    >>>>
    >>>

    >>
     
    Willy Van den Driessche, Jun 8, 2006
    #5
    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. Hazzard
    Replies:
    2
    Views:
    590
    Yan-Hong Huang[MSFT]
    Jul 23, 2003
  2. Marina
    Replies:
    0
    Views:
    566
    Marina
    Jul 21, 2003
  3. Elliot M. Rodriguez
    Replies:
    0
    Views:
    631
    Elliot M. Rodriguez
    Jul 21, 2003
  4. Natty Gur
    Replies:
    0
    Views:
    498
    Natty Gur
    Jul 22, 2003
  5. feng
    Replies:
    1
    Views:
    3,214
    Peter Rilling
    Feb 29, 2004
Loading...

Share This Page