PC Review


Reply
Thread Tools Rate Thread

ASP Composite Web Control and Position

 
 
Craig Glencross
Guest
Posts: n/a
 
      17th Jan 2008
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.


 
Reply With Quote
 
 
 
 
bruce barker
Guest
Posts: n/a
 
      17th Jan 2008
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.
>
>

 
Reply With Quote
 
Craig Glencross
Guest
Posts: n/a
 
      17th Jan 2008
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.
> >
> >

 
Reply With Quote
 
Milosz Skalecki [MCAD]
Guest
Posts: n/a
 
      18th Jan 2008
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.
> > >
> > >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how do i ensure that a composite control support Web control Template rote Microsoft ASP .NET 0 30th Sep 2008 07:11 AM
Capture an Event in a composite control From control on a page gdick@kerrhenderson.com Microsoft ASP .NET 1 10th Aug 2006 05:17 PM
Composite control with dynamic composite controls sleigh Microsoft ASP .NET 1 12th Feb 2004 06:24 PM
Using Table control in a custom composite control. Control does not render properly in design time. jb_in_marietta@yahoo.com Microsoft ASP .NET 0 1st Jul 2003 10:26 PM
composite control Jason Microsoft ASP .NET 0 25th Jun 2003 05:53 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:16 AM.