Q: Why ViewState a Style object???

Discussion in 'ASP .Net Web Controls' started by Sky Sigal, Aug 12, 2004.

  1. Sky Sigal

    Sky Sigal Guest

    I guess my question is:

    "Even if all the docs talk about making CompositeControls that serialize their multiple Style
    objects into the ViewState object -- is there any reason that you can think of? Or can I safely get
    rid of it?"

    Let me explain:

    It just sort of struck me 10 minutes ago that it might be time for me to requestion/confirm
    something that I have been taking for granted -- but maybe I shouldn't..?

    The question is: Why are we ViewStating/Serializing/Sending Style objects and round tripping them to
    the client ? I know that sounds like a dumb question ...and frankly
    I wouldn't care that much for the lost bandwidth for most of my controls -- but the one I am working
    on currently has 5 or 6 views -- each with 5 or 6 Styles that could be used.
    Serializing that whole thing is ...potentially huge.

    And for what gain?


    Consider a simple control
    <CC:SomeControl style='border:solid 1px red;color:BLUE;font-family:Verdana;' Text=""/>

    Assuming that somwhere on th page a button is clicked that we then decide to set the control's text
    color to RED....Well...according to the net documentation I have I would be serializing the whole
    Style--and sending it to the client just to track that.

    Whereas
    Render(){
    if (ViewState["Clicked"]!=null){
    MyControl.ForeColor=Color.Red;
    }
    }

    would have done the same thing without sending all that weight to the client.


    What's your opinion?
     
    Sky Sigal, Aug 12, 2004
    #1
    1. Advertising

  2. Sky Sigal

    Teemu Keiski Guest

    Re: Why ViewState a Style object???

    Well,

    you could also set style property individually, if that's what you mean.

    MyControl.Style["color"]="red";

    or the second approach is just by manipulating style attributes via
    Attributes collection.

    And to your original question, it of coiurse depends what else you have in
    the Style that gets rendered. When you set ForeColor property, you are
    setting actually your control's Style object's one property. ForeColor on
    web control maps to ControlStyle.ForeColor and ControlStyle is the main
    style object (of type System.Web.UI.WebControls.Style) which contains all
    the style properties. So when there is something in the Style, that
    something gets rendered.

    If I misunderstood your question, please correct me, and I'll try to help
    you with your issue.

    --
    Teemu Keiski
    MCP, Microsoft MVP (ASP.NET), AspInsiders member
    ASP.NET Forum Moderator, AspAlliance Columnist
    http://blogs.aspadvice.com/joteke



    "Sky Sigal" <> wrote in message
    news:...
    > I guess my question is:
    >
    > "Even if all the docs talk about making CompositeControls that serialize

    their multiple Style
    > objects into the ViewState object -- is there any reason that you can

    think of? Or can I safely get
    > rid of it?"
    >
    > Let me explain:
    >
    > It just sort of struck me 10 minutes ago that it might be time for me to

    requestion/confirm
    > something that I have been taking for granted -- but maybe I shouldn't..?
    >
    > The question is: Why are we ViewStating/Serializing/Sending Style objects

    and round tripping them to
    > the client ? I know that sounds like a dumb question ...and frankly
    > I wouldn't care that much for the lost bandwidth for most of my

    controls -- but the one I am working
    > on currently has 5 or 6 views -- each with 5 or 6 Styles that could be

    used.
    > Serializing that whole thing is ...potentially huge.
    >
    > And for what gain?
    >
    >
    > Consider a simple control
    > <CC:SomeControl style='border:solid 1px

    red;color:BLUE;font-family:Verdana;' Text=""/>
    >
    > Assuming that somwhere on th page a button is clicked that we then decide

    to set the control's text
    > color to RED....Well...according to the net documentation I have I would

    be serializing the whole
    > Style--and sending it to the client just to track that.
    >
    > Whereas
    > Render(){
    > if (ViewState["Clicked"]!=null){
    > MyControl.ForeColor=Color.Red;
    > }
    > }
    >
    > would have done the same thing without sending all that weight to the

    client.
    >
    >
    > What's your opinion?
    >
    >
    >
    >
    >
    >
    >
    >
    >
    >
     
    Teemu Keiski, Aug 14, 2004
    #2
    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. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    921
    Mark Rae
    Dec 21, 2006
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,073
    Smokey Grindel
    Dec 2, 2006
  3. Kza
    Replies:
    4
    Views:
    430
    Andrew Koenig
    Mar 3, 2006
  4. Ken Varn
    Replies:
    0
    Views:
    492
    Ken Varn
    Apr 26, 2004
  5. Jake Barnes
    Replies:
    6
    Views:
    202
    Lawrence Krubner
    Apr 12, 2009
Loading...

Share This Page