ASP Composite Web Control and Position

C

Craig Glencross

I have created a Composite Control in C# 2005 for ASP. It has 3 buttons, a
calendar control and some drop down lists.

It compiles correctly and I can use it on a test web site but I cannot
control where to place it on the web page.

I have tried positioning tags such as relative or absoulte. Can you explain
what I am missing? Do I have to expose the style property? Her e is the
Render function:


//-------------------------------------------------------------------------------
// Place the child controls in the correct positions on this control

//-------------------------------------------------------------------------------
public override void RenderControl(HtmlTextWriter writer)
{

writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
txtCalendar.RenderControl(writer);
btnCalendar.RenderControl(writer);
writer.RenderEndTag(); // td
writer.RenderEndTag(); // tr

writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
calMain.RenderControl(writer);
writer.RenderEndTag(); // td
writer.RenderEndTag(); // tr

writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
ddlHours.RenderControl(writer);
ddlMinutesMajor.RenderControl(writer);
ddlMinutesMinor.RenderControl(writer);
ddlAMorPM.RenderControl(writer);
writer.RenderEndTag(); // td
writer.RenderEndTag(); // tr

writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
btnUpdate.RenderControl(writer);
btnCancel.RenderControl(writer);
writer.RenderEndTag(); // td
writer.RenderEndTag(); // tr


writer.RenderEndTag(); // table
}



Thanks.
 
B

bruce barker

your parent control (the table) does not render any of the position
attributes (style) that may be specified by the designer or page source. you
should render any style attributes and the cssclass if specified.

-- bruce (sqlwork.com)
 
C

Craig Glencross

I am new to this. Can you please explain how to do the render of the
position attributes?

Thanks in advance.
 
M

Milosz Skalecki [MCAD]

Hi there,

// tag attributes must be added before the corresponding tag

writer.AddStyleAttribute(HtmlTextWriterStyle.Position, "absolute");
writer.RenderBeginTag(HtmlTextWriterTag.Table);
writer.RenderBeginTag(HtmlTextWriterTag.Tr);
writer.RenderBeginTag(HtmlTextWriterTag.Td);
//.. etc

Hope this helps
 

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,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top