ASP Composite Web Control and Position

ASP Composite Web Control and Position

am 17.01.2008 15:38:00 von 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.

RE: ASP Composite Web Control and Position

am 17.01.2008 17:23:01 von brucebarker

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)


"Craig Glencross" wrote:

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

RE: ASP Composite Web Control and Position

am 17.01.2008 20:44:00 von CraigGlencross

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

Thanks in advance.




"bruce barker" wrote:

> 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)
>
>
> "Craig Glencross" wrote:
>
> > 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.
> >
> >

RE: ASP Composite Web Control and Position

am 18.01.2008 21:08:00 von mily242

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
--
Milosz


"Craig Glencross" wrote:

> I am new to this. Can you please explain how to do the render of the
> position attributes?
>
> Thanks in advance.
>
>
>
>
> "bruce barker" wrote:
>
> > 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)
> >
> >
> > "Craig Glencross" wrote:
> >
> > > 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.
> > >
> > >