Design Time Rendering Within Tables

J

James F. Kubecki

Hello,
I'm attempting to build a composite control which for
purposes of layout renders its content as an HTML table
row (<tr>). At runtime, it works just fine, but at
design time, the control doesn't render at all.
The following is a simplified example which will
illustrate this:

(CONTROL CLASS)

public class RowTypeControl : Control
{
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<tr><td>Foo</td><td>Bar</td></tr>");
}
}

(ASPX PAGE)

<table border=5>
<cc1:RowTypeControl id="RowTypeControl1"
runat="server"></cc1:RowTypeControl>
</table>

Again, at runtime, this renders perfectly, but at design
time, it doesn't show ANYTHING in the designer.

What am I missing?
JFK
 
V

Victor Garcia Aprea [MVP]

Hi James,

Based on your posted Render method, it should render ok. Could you post a
very small sample to repro this?

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 
J

James F. Kubecki

Hi,
Not sure what you need beyond the sample that was
originally posted. Can you elaborate?

JFK
 
V

Victor Garcia Aprea [MVP]

The RowTypeControl you just posted is *really* very simple and should work
okay. I'm guessing your real code its a bit different and it may contain
something that its causing the unexpected behavior. Could you describe what
exactly is being rendered on the design-surface? Nothing at all? Are you
able to select the control and move it around? Also if the control is not
apparently showing try selecting with the mouse a big region to see if
anything becomes selected.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 
J

James F. Kubecki

Oh OK. The RowTypeControl example shown below IS much
simpler than the "real code", HOWEVER it behaves exactly
the same way.
Specifically, on the design surface, NOTHING is
rendered. There is not even a handle for selecting the
control. If you select the control in the properties
window or in Document Outline, there is no change to the
rendered view to indicate that anything selected.

Also, if you add any other table rows, those rows are
rendered (so you can now see the table) but the control
remains unrendered.

Example:
<table border=5>
<tr>
<td>Foo</td>
<td>Bar</td>
</tr>
<cc1:RowTypeControl id="RowTypeControl1"
runat="server"></cc1:RowTypeControl>
<tr>
<td>Foo</td>
<td>Bar</td>
</tr>
</table>

Renders as:

+---+---+
|Foo|Bar|
+---+---+
|Foo|Bar|
+---+---+

The rendering above is simulated, of course... :)

JFK
 
V

Victor Garcia Aprea [MVP]

Please try creating a brand new test web app project (to isolate as much as
possible from your current project), include the code for the control you
posted and see how it works. If you still don't get any design-time support
then I'm guessing your VS.NET installation may have been corrupted or
something.

--
Victor Garcia Aprea
Microsoft MVP | ASP.NET
Looking for insights on ASP.NET? Read my blog:
http://obies.com/vga/blog.aspx
To contact me remove 'NOSPAM'. Please post all questions to the newsgroup
and not by private mail.
 
A

Andrew

From what I have learned, the chunk of html you generate in Render will be
separate from any html in the page.

The simplest illustration of this is touse two literal, one has .Text to
open a table, the other to close it.
This will work at runtime for the browser, but the designer surface will not
show them as a single table.

While I doubt it is what you want, you can check my meaning by putting the
html for the table into the custom control's render method (with the row and
cell tags).

To get around this, you could try working with the asp:table or building
annother table control of your own, that will render the table tags and your
custom row controls.

-Andrew Stevenson
UITemplates.net
 

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,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top