prevent runat="server"

  • Thread starter Willy Van den Driessche
  • Start date
W

Willy Van den Driessche

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
 
N

Nathan Sokalski

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.
 
W

Willy Van den Driessche

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).
 
M

mnichols

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
 
W

Willy Van den Driessche

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top