Results 1 to 2 of 2

Thread: [2005] Styles and Custom Controls

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Mar 2006
    Location
    Madrid
    Posts
    325

    [2005] Styles and Custom Controls

    Hi,
    I´m reading a book on custom controls, "Wrox ASP.Net 2.0 Server Control Development",..
    And have come accross something I do not fully understand,..

    If you override the CreateControlStyle method so you return a TableSyle, why is there a need to pass the viewstate of the control to the style object.

    http://msdn2.microsoft.com/en-us/lib...le(VS.80).aspx

    Code:
    protected override Style CreateControlStyle()
    {
    return new TableStyle(ViewState);
    }

    The thing is further on in the chapter it creates its own customStyleTable Object, so it includes certain properties which the TableStyle doesn´t include,..
    Well not going into too much detail, but it stores it´s values in viewstate.

    Which confuses me, so does viewstate also store style values?

    The source code, displays all the attributes assigned to the control,
    for instance:

    HTML Code:
    <div>
            <table id="rauland" style="background-color:#FFC0C0;">
    	<tr>
    		<td>Hello people</td>
    	</tr>
    </table>
        </div>
    Background-color, appears as is in the table. So why is there a need to make the controls viewstate available to the style object?

    THanks,
    Rauland

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: [2005] Styles and Custom Controls

    I suppose it'd be because this method could be applied to more complex controls which have other properties and styles. Viewstates could hold styles, but it'd also hold other properties associated with all of the controls on the page. Hence the need for passing the viewstate.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width