Changing skinId on custom ASP.net control HELP!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • V

    Changing skinId on custom ASP.net control HELP!

    Hello!

    I made custom control with tables and labels in it.
    In my page I have several of these controls. Each one should have
    different color of tables etc.
    I have different SkinIDs for that.
    When my Default page loads I'd like to set SkinID for each of these
    controls.


    I understand that Page_PreInit should have this but I can't access my
    control's properties from there.
    I also know that control can't have PreInit, only Page.


    I spent last ten hours trying to get around this. I don't know what to
    do. HELP


    Thank you,
    Hrvoje

  • Ananth Ramasamy Meenachi

    #2
    RE: Changing skinId on custom ASP.net control HELP!

    Hi,

    Use the followig code for tablerow

    using System;
    using System.Web.UI;
    using System.Web.UI.W ebControls;
    using System.Componen tModel;

    namespace PubsPortal.cont rols.display
    {
    /// <summary>
    /// Summary description for TableRow.
    /// </summary>
    [DefaultProperty ("Text"),
    ToolboxData("<{ 0}:TableRow runat=server></{0}:TableRow>")]
    public class TableRow : System.Web.UI.W ebControls.Tabl eRow
    {
    /// <summary>
    /// Render this control to the output parameter specified.
    /// </summary>
    /// <param name="output"Th e HTML writer to write out to </param>
    protected override void Render(HtmlText Writer output)
    {
    // debug info
    // this.ToolTip = this.Parent.Get Type().ToString ();


    // better way (instead of checking repeateritem) of doing this
    // is to check for odd/even control indexes...
    // that way tables without repeater
    //int RowCount = this.Parent.Con trols.Count;

    if (this.Parent.Ge tType().ToStrin g() ==
    "System.Web.UI. WebControls.Rep eaterItem" )
    {
    System.Web.UI.W ebControls.Repe aterItem parentItem =
    (System.Web.UI. WebControls.Rep eaterItem)this. Parent;

    if (parentItem.Ite mType == ListItemType.Al ternatingItem )
    {
    this.Attributes["bgcolor"]="#f3f9fd";
    this.Attributes["height"]="20";
    }
    }
    base.Render(out put);
    }

    /// <summary>
    ///
    /// </summary>
    /// <param name="writer"></param>
    public override void RenderEndTag(Ht mlTextWriter writer)
    {
    writer.WriteEnd Tag("tr");
    writer.WriteLin e();
    writer.Indent--;

    }
    }
    }


    Ananth Ramasamy Meenachi
    Programmer Analyst



    "V" wrote:
    Hello!
    >
    I made custom control with tables and labels in it.
    In my page I have several of these controls. Each one should have
    different color of tables etc.
    I have different SkinIDs for that.
    When my Default page loads I'd like to set SkinID for each of these
    controls.
    >
    >
    I understand that Page_PreInit should have this but I can't access my
    control's properties from there.
    I also know that control can't have PreInit, only Page.
    >
    >
    I spent last ten hours trying to get around this. I don't know what to
    do. HELP
    >
    >
    Thank you,
    Hrvoje
    >
    >

    Comment

    Working...