ASP Composite Web Control and Position

Discussion in 'ASP .Net' started by Craig Glencross, Jan 17, 2008.

  1. 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.
     
    Craig Glencross, Jan 17, 2008
    #1
    1. Advertising

  2. Craig Glencross

    bruce barker Guest

    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.
    >
    >
     
    bruce barker, Jan 17, 2008
    #2
    1. Advertising

  3. 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.
    > >
    > >
     
    Craig Glencross, Jan 17, 2008
    #3
  4. 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.
    > > >
    > > >
     
    Milosz Skalecki [MCAD], Jan 18, 2008
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. sleigh
    Replies:
    1
    Views:
    2,691
    sleigh
    Feb 12, 2004
  2. shapper
    Replies:
    6
    Views:
    956
    shapper
    Dec 26, 2007
  3. Chad
    Replies:
    0
    Views:
    224
  4. James Wong
    Replies:
    4
    Views:
    499
    James Wong
    Jul 14, 2004
  5. Mike

    Composite vs non composite Controls

    Mike, Mar 10, 2005, in forum: ASP .Net Web Controls
    Replies:
    4
    Views:
    265
    Sundararajan
    Mar 11, 2005
Loading...

Share This Page