473,386 Members | 1,830 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,386 software developers and data experts.

ApplyStyle, Copyfrom, Merge and Styles -- and impact on ViewState.

Hello:
I'm having a little trouble understanding how to effectively offer Style
control on the subelements of a Composite control.
The book I have is pointing towards a certain set of steps that appears to
save the info TWICE...but I am not sure....could someone take a look?

The steps suggested are approximately:

a) Create a webcontrol that has two inner Controls (a TextBox and Button)
b) provide public properties for each inner control's Style:
public Style StyleForInnerTextBox {
get {
if (_StyleForInnerTextBox==null){
_StyleForInnerTextBox = new Style();
if
(IsTrackingViewState){((IsTrackingViewState)StyleF orInnerTextBox).TrackViewS
tate();};
}
}
public Stylle StyleForInnerButton {same thing...}
etc.
c) override the Control's LoadViewState and SaveViewState in order to save
an array of viewstates:

override object SaveViewState(){
object tBlobs = new object[2];
tBlobs[0] = base.SaveViewState();
tBlobs[1] = new
object{StyleForInnerTextBox.SaveViewState(),StyleF orInnerButton.SaveViewStat
e()};
return tBlobs;
}

override void LoadViewState(object ViewState){
object[] tBlobs = ViewState;
object tOrigViewState = tBlobs[0];
object tMyExtraViewState = tBlobs[1];
base.LoadViewState[tOrigViewState];
StyleForInnerTextBox.ApplyStyle[tMyExtraViewState[0]];
StyleForInnerButton.ApplyStyle[tMyExtraViewState[1]];
}

d) In PreRender use the ApplyStyle to change the inner textbox's style:

PreRender(){
StyleForInnerTextBox.ApplyStyle(_StyleForInnerText Box);
StyleForInnerButton.ApplyStyle(_StyleForInnerButto n);
}
What worries me is that the ViewState of the InnerTextBox is being passed up
to the WebControl's viewState -- and then I am saving it again a second time
manually via the second copy (tMyExtraViewState[0]).
Therefore -- this doesn't seem right to me.

Why is it being suggested to use external Style objects -- when the
following would have worked:

public Style InnerTextBoxStyle {EnsureChildControls();return
InnerTextBox.ControlStyle;}

Thank you very very much!
Sky



Nov 18 '05 #1
0 1031

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

Similar topics

6
by: Marcin Kalicinski | last post by:
Hi, In the following code example: class Base { virtual void CopyFrom(const Base *); }; class Derived: public Base { void CopyFrom(const Derived *);
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
3
by: Steve Drake | last post by:
All, I have a CONTROL that contains 1 control (Control ONE), the 1 control that it can contain 1 or 2 control (Control A and B). Control A, raises and event and Control ONE receives this event...
10
by: neo | last post by:
hi, I am studying ASP.NET and have few questions - 1) The session ID and values of controls is stored in VIEWSTATE variable. So now when we put EnableViewState="false" in Page directive and...
1
by: Simon | last post by:
Hi everyone, I have a quick question that I hope someone can help me with: I've made a user control that contains a text box and some validation functionality. This control has a few extra...
7
by: et | last post by:
I'm not sure I understand the use of the ViewState. Do I understand correctly that values of controls are automatically held in a hidden control called ViewState? If so, then why can't we get...
3
by: RCS | last post by:
I have an app that I have different "sections" that I want to switch back and forth from, all while having the server maintain viewstate for each page. In other words, when I am on Page1.aspx and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.