473,395 Members | 1,473 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Public Poll/advice on designing Controls that need Styles to look good...How?!?

Hello:
I'm currently messing around, and need as much feedback/help as I can get, trying to find the most
economical/graceful way to build usercontrols that rely on styling to look any good...

It's the last part that has got me all frazzled (the 'rely on...to look good')...

Let me explain -- and please bear with me as it's a bit longer than my usual questions:

I've seen a lot of articles and books on how to make Controls, and how to expose CSS properties via
the Style objects, and how to use SaveViewState/LoadViewState to hold them...

It appears that if designing a control that is to draw 50 images, each to be styled with the same
Style rules, that what is recommended as best practice is something like:

MyControl {

//Define a public property to expose a style for the inner elements:
public Style StyleImage{get {if (_StyleButton == null){_StyleButton= new
Style();((IStateManager)_StyleButton).TrackViewSta te();}return _StyleImage;}
private Style _StyleImage;

//....usual suspects (override LoadViewState/SaveViewState)

//...somewhere about here we actually give some values to the style object before we use it:
_StyleImage.BorerStyle = BorderStyle.Solid;
_StyleImage.BorderColor Color.Red;
_StyleImage.BorderWidth = Unit.Pixel(1);
_StyleImage.Height = Unit.Pixel(16);
_StyleImage.Width = Unit.Pixel(16);

//Finally, apply the styling:
protected void override Render(HtmlTextWriter writer){
//And after ViewState has been saved...
//Apply the common style so there is no ViewState bloat.
for (int i=0;i<50;i++){
Image tImg = new Image();
tImg.ApplyStyle(_StyleImage;} // <--Apply the Style...

this.Controls.Add(tImg;}
}
}

Looks about right, no?
What I am suprised about in first place is to hear NOBODY complain the least that this would bloat
the outgoing stream with:

<img style='border:solid 1px red;width:16px;height:16px;margin:10px;'>...</img>
<img style='border:solid 1px red;width:16px;height:16px;margin:10px;'>...</img>
<img style='border:solid 1px red;width:16px;height:16px;margin:10px;'>...</img>
<img style='border:solid 1px red;width:16px;height:16px;margin:10px;'>...</img>
....

when:

<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>

would have done it -- and been more to the norms to boot.

Ok. ..So you say, that too can be done by using the Style.CssClass value to achieve this:

True...and I've been trying to use it. I'm just suprised that it doesn't raise more of a stink...
Moving right along...because that's not the question/point of this query...

The point is I've gotten myself into a fix trying to figure out what is the most graceful way to
design webcontrols...that rely on style sheets to look correct.
For example:
Currently I am mucking around designing a webcontrol for calendars in week/day/quarter/etc. views...
relies on a lot of different Styles to lay it all out.

If I render it with it with no Styling applied at all, just placement of cells, etc, it looks like
absolute hell.

It really needs default styling to be included in the control.
I can default each style to what is the css code for it -- or default it to point to a css file.

eg:

a) Style _CalendarCell = new Style(); _CalendarCell.BackColor =
Color.Almond;ForeColor=Color.Black...etc...
or:
b) Style _CalendarCell = new Style(); _CalendarCell.CssClass =
"STYLE_IN_SOME_SHEET_THAT_IS_CURRENTLY_MISSING "
If I use version a, that's nice -- it looks good, but I just bloated the poor guys viewstate for no
reason except laziness on my part.

If I use b), that's nicer to his VS -- but the first time he drops the control on his page, it looks
all wrong...nothing will be sized right, colored etc...and will be all out of whack till he/she
includes a CSS sheet.
That is assuming that he will find out how my control is put together and what needs to be styled
how.

c) Option 3...-- I could do b) -- but then also include a StyleSheet as a resource and feed it into
the page....So now the control would need to have a public bool that looks like:

bool IncludeResouceCSS=true;

that will include or not a <link src='ResourceHandler'> in the output or not -- which the user can
override.

Option 3 looks like the most flexible to me -- but I am having a lot of trouble putting it into
practice.

So about now, I am pretty frustrated by how the Net Framwork has not clearly shown a way to do this
type of control designing -- and would like input from people who have done this before...
Could someone who has done this before post your comments as what you suggest as a good way to
tackle this problem?

Thank you so much,
Sky

Nov 18 '05 #1
2 1387
webcontrols have the CssClass property, which is the techinque for specifing
the class, controls like the grid will have several properties for setting
the style. if the class is not specified, then inline style is used.

-- bruce (sqlwork.com)

"Sky Sigal" <as*******@xact-solutions.removethis.com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
Hello:
I'm currently messing around, and need as much feedback/help as I can get, trying to find the most economical/graceful way to build usercontrols that rely on styling to look any good...
It's the last part that has got me all frazzled (the 'rely on...to look good')...
Let me explain -- and please bear with me as it's a bit longer than my usual questions:
I've seen a lot of articles and books on how to make Controls, and how to expose CSS properties via the Style objects, and how to use SaveViewState/LoadViewState to hold them...
It appears that if designing a control that is to draw 50 images, each to be styled with the same Style rules, that what is recommended as best practice is something like:

MyControl {

//Define a public property to expose a style for the inner elements:
public Style StyleImage{get {if (_StyleButton == null){_StyleButton= new
Style();((IStateManager)_StyleButton).TrackViewSta te();}return _StyleImage;} private Style _StyleImage;

//....usual suspects (override LoadViewState/SaveViewState)

//...somewhere about here we actually give some values to the style object before we use it: _StyleImage.BorerStyle = BorderStyle.Solid;
_StyleImage.BorderColor Color.Red;
_StyleImage.BorderWidth = Unit.Pixel(1);
_StyleImage.Height = Unit.Pixel(16);
_StyleImage.Width = Unit.Pixel(16);

//Finally, apply the styling:
protected void override Render(HtmlTextWriter writer){
//And after ViewState has been saved...
//Apply the common style so there is no ViewState bloat.
for (int i=0;i<50;i++){
Image tImg = new Image();
tImg.ApplyStyle(_StyleImage;} // <--Apply the Style...

this.Controls.Add(tImg;}
}
}

Looks about right, no?
What I am suprised about in first place is to hear NOBODY complain the least that this would bloat the outgoing stream with:

<img style='border:solid 1px red;width:16px;height:16px;margin:10px;'>...</img> <img style='border:solid 1px red;width:16px;height:16px;margin:10px;'>...</img> <img style='border:solid 1px red;width:16px;height:16px;margin:10px;'>...</img> <img style='border:solid 1px red;width:16px;height:16px;margin:10px;'>...</img> ...

when:

<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>

would have done it -- and been more to the norms to boot.

Ok. ..So you say, that too can be done by using the Style.CssClass value to achieve this:
True...and I've been trying to use it. I'm just suprised that it doesn't raise more of a stink...

Moving right along...because that's not the question/point of this query...
The point is I've gotten myself into a fix trying to figure out what is the most graceful way to design webcontrols...that rely on style sheets to look correct.
For example:
Currently I am mucking around designing a webcontrol for calendars in week/day/quarter/etc. views... relies on a lot of different Styles to lay it all out.

If I render it with it with no Styling applied at all, just placement of cells, etc, it looks like absolute hell.

It really needs default styling to be included in the control.
I can default each style to what is the css code for it -- or default it to point to a css file.
eg:

a) Style _CalendarCell = new Style(); _CalendarCell.BackColor =
Color.Almond;ForeColor=Color.Black...etc...
or:
b) Style _CalendarCell = new Style(); _CalendarCell.CssClass =
"STYLE_IN_SOME_SHEET_THAT_IS_CURRENTLY_MISSING "
If I use version a, that's nice -- it looks good, but I just bloated the poor guys viewstate for no reason except laziness on my part.

If I use b), that's nicer to his VS -- but the first time he drops the control on his page, it looks all wrong...nothing will be sized right, colored etc...and will be all out of whack till he/she includes a CSS sheet.
That is assuming that he will find out how my control is put together and what needs to be styled how.

c) Option 3...-- I could do b) -- but then also include a StyleSheet as a resource and feed it into the page....So now the control would need to have a public bool that looks like:
bool IncludeResouceCSS=true;

that will include or not a <link src='ResourceHandler'> in the output or not -- which the user can override.

Option 3 looks like the most flexible to me -- but I am having a lot of trouble putting it into practice.

So about now, I am pretty frustrated by how the Net Framwork has not clearly shown a way to do this type of control designing -- and would like input from people who have done this before... Could someone who has done this before post your comments as what you suggest as a good way to tackle this problem?

Thank you so much,
Sky

Nov 18 '05 #2
And that doesn't BOTHER anyone??

Let's say you are Rendering a year calendar (7days*6rows*12months)=504cells.
Now style that up with nothing too fancy:
style='background-color:red;font-size:7pt;font-style:underline;font-weight:bold;'

which is 74 chars... -- which leads to 30k -- just for the cell. --Now add a ITemplate within, some
text and easily duplicate the num of characters ... 200 is more like it in the end.

200 x 504 = 100k.

Thats 20 seconds of download on a 54k modem -- and we havn't even discussed ViewState.

That doesn't strike anybody as wrong? Lazy?
What happened to giving a s**t about the quality of html/css we are ejecting -- or are we no longer
suppossed to care, since it is all done somewhere in the framework, and its no longer our duty to
investigate/modify...or worse "interfere" with the Framework? Because that really really gets my
goat. But maybe its because I used to do php day in day out.
Anybody have arguments to give as to why this is ok? Or if you agree with me that its not great, any
suggestions as to what we can do about it?

"bruce barker" <no***********@safeco.com> wrote in message
news:u1*************@TK2MSFTNGP11.phx.gbl...
webcontrols have the CssClass property, which is the techinque for specifing
the class, controls like the grid will have several properties for setting
the style. if the class is not specified, then inline style is used.

-- bruce (sqlwork.com)

"Sky Sigal" <as*******@xact-solutions.removethis.com> wrote in message
news:O8**************@tk2msftngp13.phx.gbl...
Hello:
I'm currently messing around, and need as much feedback/help as I can get,

trying to find the most
economical/graceful way to build usercontrols that rely on styling to look

any good...

It's the last part that has got me all frazzled (the 'rely on...to look

good')...

Let me explain -- and please bear with me as it's a bit longer than my

usual questions:

I've seen a lot of articles and books on how to make Controls, and how to

expose CSS properties via
the Style objects, and how to use SaveViewState/LoadViewState to hold

them...

It appears that if designing a control that is to draw 50 images, each to

be styled with the same
Style rules, that what is recommended as best practice is something like:

MyControl {

//Define a public property to expose a style for the inner elements:
public Style StyleImage{get {if (_StyleButton == null){_StyleButton= new
Style();((IStateManager)_StyleButton).TrackViewSta te();}return

_StyleImage;}
private Style _StyleImage;

//....usual suspects (override LoadViewState/SaveViewState)

//...somewhere about here we actually give some values to the style object

before we use it:
_StyleImage.BorerStyle = BorderStyle.Solid;
_StyleImage.BorderColor Color.Red;
_StyleImage.BorderWidth = Unit.Pixel(1);
_StyleImage.Height = Unit.Pixel(16);
_StyleImage.Width = Unit.Pixel(16);

//Finally, apply the styling:
protected void override Render(HtmlTextWriter writer){
//And after ViewState has been saved...
//Apply the common style so there is no ViewState bloat.
for (int i=0;i<50;i++){
Image tImg = new Image();
tImg.ApplyStyle(_StyleImage;} // <--Apply the Style...

this.Controls.Add(tImg;}
}
}

Looks about right, no?
What I am suprised about in first place is to hear NOBODY complain the

least that this would bloat
the outgoing stream with:

<img style='border:solid 1px

red;width:16px;height:16px;margin:10px;'>...</img>
<img style='border:solid 1px

red;width:16px;height:16px;margin:10px;'>...</img>
<img style='border:solid 1px

red;width:16px;height:16px;margin:10px;'>...</img>
<img style='border:solid 1px

red;width:16px;height:16px;margin:10px;'>...</img>
...

when:

<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>
<img class="MYCLASS">...</img>

would have done it -- and been more to the norms to boot.

Ok. ..So you say, that too can be done by using the Style.CssClass value

to achieve this:

True...and I've been trying to use it. I'm just suprised that it doesn't

raise more of a stink...


Moving right along...because that's not the question/point of this

query...

The point is I've gotten myself into a fix trying to figure out what is

the most graceful way to
design webcontrols...that rely on style sheets to look correct.
For example:
Currently I am mucking around designing a webcontrol for calendars in

week/day/quarter/etc. views...
relies on a lot of different Styles to lay it all out.

If I render it with it with no Styling applied at all, just placement of

cells, etc, it looks like
absolute hell.

It really needs default styling to be included in the control.
I can default each style to what is the css code for it -- or default it

to point to a css file.

eg:

a) Style _CalendarCell = new Style(); _CalendarCell.BackColor =
Color.Almond;ForeColor=Color.Black...etc...
or:
b) Style _CalendarCell = new Style(); _CalendarCell.CssClass =
"STYLE_IN_SOME_SHEET_THAT_IS_CURRENTLY_MISSING "
If I use version a, that's nice -- it looks good, but I just bloated the

poor guys viewstate for no
reason except laziness on my part.

If I use b), that's nicer to his VS -- but the first time he drops the

control on his page, it looks
all wrong...nothing will be sized right, colored etc...and will be all out

of whack till he/she
includes a CSS sheet.
That is assuming that he will find out how my control is put together and

what needs to be styled
how.

c) Option 3...-- I could do b) -- but then also include a StyleSheet as a

resource and feed it into
the page....So now the control would need to have a public bool that looks

like:

bool IncludeResouceCSS=true;

that will include or not a <link src='ResourceHandler'> in the output or

not -- which the user can
override.

Option 3 looks like the most flexible to me -- but I am having a lot of

trouble putting it into
practice.

So about now, I am pretty frustrated by how the Net Framwork has not

clearly shown a way to do this
type of control designing -- and would like input from people who have

done this before...
Could someone who has done this before post your comments as what you

suggest as a good way to
tackle this problem?

Thank you so much,
Sky


Nov 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

44
by: Carl | last post by:
"Nine Language Performance Round-up: Benchmarking Math & File I/O" http://www.osnews.com/story.php?news_id=5602 I think this is an unfair comparison! I wouldn't dream of developing a numerical...
32
by: Alan Silver | last post by:
Hello, I shamefully admit to be an old web designer, from before the days of CSS. In those heady days, tables were king and were used for every possible kind of alignment. When CSS came along,...
4
by: Marius Trælnes | last post by:
Hello! I am about to make a class/control that creates tabbing functionality. The result is in HTML/CSS/JavaScript output. My question is: Within the tabs I want to simply add user controls...
4
by: Joe | last post by:
Hi, I am thinking about designing a website using HTML/ASP.NET. I am expecting that the website will have about 50-100 pages. I am planning on using SSI to separate the sections of the pages...
4
by: Web_PDE_Eric | last post by:
I don't know where to go, or what to buy, so plz re-direct me if I'm in the wrong place. I want to do high performance integration of partial differential eqns in n dimensions (n=0,1,2,3..etc) I...
2
by: jack | last post by:
Hi all, im in a middle of an project and it is going pretty well. But one this that is always in back of my mind is the interface design. every day i look at it i tend to change either the...
4
by: Bugs | last post by:
Hi, I wonder if anyone can help me out. I'm building a vb.net application that has a form with a panel that contains several other sub forms (as a collection of controls). What I'm wanting to...
4
by: MPA | last post by:
Hi, We are a small company with experience in client-server apps with PowerBuilder and most major databases. We have no internet experience. We are now looking into slimming our main application,...
92
by: Jim Langston | last post by:
Someone made the statement in a newsgroup that most C++ programmers use smart pointers. His actual phrase was "most of us" but I really don't think that most C++ programmers use smart pointers,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.