473,802 Members | 2,172 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

not persisting control after viewing design time?

I have a custom server web control that inserts another custom web server
control in a templated child control (a wisard that inserts a header in its
wizardstep)
Now after switching to design view and back the header is inserted in the
aspx page's xml. I don't want this because then yet another header is
inserted when I switch to design view again.
I've tried looking through the attributes you can set on a component but I
can't find anything that stops serialization of an entire component, only a
property or event.

How can I stop the design view from actually inserting the header into the
xml of the wizard step template?

Kind Regards,
Allan Ebdrup
Jul 16 '07 #1
10 1603
Hi Allan,

I'm not sure if I fully understand your question. What kind of header in
the WizardStep?

If this is the same control you mentioned in your another post, I think I
can also help you after you send me a reproducible project. Thanks.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 17 '07 #2

"Walter Wang [MSFT]" <wa****@online. microsoft.comwr ote in message
news:iK******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Allan,

I'm not sure if I fully understand your question. What kind of header in
the WizardStep?

If this is the same control you mentioned in your another post, I think I
can also help you after you send me a reproducible project. Thanks.
The header is my own web server user control
I found a solution, instead of adding the header to all the wizardsteps I
add the header in the HeaderContainer of the wizard:
------
protected override void OnInit(EventArg s e)
{
if (ShowCustomHead er)
{
this.HeaderText = " "; //we need this to render header.
Control wizardHeader = this.FindContro l("HeaderContai ner") as Control;
if (wizardHeader != null)
{
CustomWizardSte pHeader header = new CustomWizardSte pHeader();
header.CustomWi zard = this;
header.ID = "CustomWizardSt epHeader";
wizardHeader.Co ntrols.AddAt(0, header);
}
}
base.OnInit(e);
}
------

It doesn't show up in design view, but I guess I can live with that...

Kind Regards,
Allan Ebdrup
Free surveys with AJAX (beta): http://obsurvey.com
Jul 19 '07 #3
Hi Allan,

Wizard inherits from CompositeContro l. We normally create child controls of
a composite control in the method CreateChildCont rols.
I suggest you to override CreateChildCont rols, call
base.CreateChil dControls first, then add your custom header. This will make
it also appear in the designer.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 20 '07 #4
"Walter Wang [MSFT]" <wa****@online. microsoft.comwr ote in message
news:cP******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Allan,

Wizard inherits from CompositeContro l. We normally create child controls
of
a composite control in the method CreateChildCont rols.
I suggest you to override CreateChildCont rols, call
base.CreateChil dControls first, then add your custom header. This will
make
it also appear in the designer.
Thank you for your feedback. I've tried your suggestion with the following
CreateChildCont rols:
--------------
protected override void CreateChildCont rols()
{
base.CreateChil dControls();
if (ShowCustomHead er)
{
Control wizardHeader = this.FindContro l("HeaderContai ner") as Control;
if (wizardHeader != null)
{
CustomWizardSte pHeader header = new CustomWizardSte pHeader();
header.CustomWi zard = this;
header.ID = "CustomWizardSt epHeader";
wizardHeader.Co ntrols.AddAt(0, header);
}
}
}
----------------------

The header shows up fine at run time, but it doesn't show up at design
time...

Kind Regards,
Allan Ebdrup
Jul 23 '07 #5
Hi Allan,

Is "ShowCustomerHe ader" a property persisted in ViewState?

Could you please put up a complete project and send it to me, I think this
might be related to other parts of your code. Thanks for the trouble.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 23 '07 #6
Hi Allan,

Thanks for the code you mailed to me.

I just realized that the "HeaderContaine r" you're using is actually used to
hold controls in the HeaderTemplate. In this case, dynamic controls added
to it will not work as usual. You will need to create a custom template and
use it as the HeaderTemplate:

public class Class1 : Wizard
{
protected override void CreateChildCont rols()
{
this.HeaderTemp late = new MyTemplate();
base.CreateChil dControls();
}
}

public class MyTemplate : ITemplate
{
public void InstantiateIn(S ystem.Web.UI.Co ntrol container)
{
Button button = new Button();
button.Text = "Hello";
container.Contr ols.Add(button) ;
}
}

This will also works at design-time.

#Creating Web Server Control Templates Dynamically
http://msdn2.microsoft.com/en-us/lib...ak(vs.71).aspx
#Creating Templates Programmaticall y in the DataGrid Control
http://msdn2.microsoft.com/en-us/lib...68(vs.71).aspx
However, please note at this time, user will not be able to use
<HeaderTemplate node in your custom wizard since you completely replaced
it; but I think your objective here is to use a built-in header for your
custom wizard control so I think this should not be an issue.

Hope this helps.

Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 25 '07 #7

"Walter Wang [MSFT]" <wa****@online. microsoft.comwr ote in message
news:93******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Allan,

Thanks for the code you mailed to me.

I just realized that the "HeaderContaine r" you're using is actually used
to
hold controls in the HeaderTemplate. In this case, dynamic controls added
to it will not work as usual. You will need to create a custom template
and
use it as the HeaderTemplate:
I created a header template:

public class CustomWizardSte pHeaderTemplate : ITemplate
{
private readonly CustomWizard _customWizard;
public CustomWizardSte pHeaderTemplate (CustomWizard customWizard)
{
_customWizard = customWizard;
}
public void InstantiateIn(C ontrol container)
{
CustomWizardSte pHeader header = new CustomWizardSte pHeader();
header.CustomWi zard = _customWizard;
header.ID = "CustomWizardSt epHeader";
container.Contr ols.Add(header) ;
}
}

And I use it in CreateChildCont rols:

protected override void CreateChildCont rols()
{
if (ShowCustomHead er)
{
this.HeaderTemp late = new CustomWizardSte pHeaderTemplate (this);
}
base.CreateChil dControls();
}

The header still does not show up in design view. It does show up correctly
at runtime...

I'll take a look at the links you send.

Kind Regards,
Allan Ebdrup
Jul 25 '07 #8
I found that I was missing EnsureChildCont rols in the Render method...

Now everything works.

Thanks for the help.

Kind Regards,
Allan Ebdrup
Jul 25 '07 #9
Hi Allan,

For a composite control, you should inherit from WebControl and
INamingContaine r; or better (in ASP.NET 2.0), inherit from CompositeContro l.

Also there're some best practice when creating composite control, please
follow the example code here:

#A Crash Course on ASP.NET Control Development: Building Composite Controls
http://msdn2.microsoft.com/en-us/library/aa479016.aspx
Hope this helps.
Regards,
Walter Wang (wa****@online. microsoft.com, remove 'online.')
Microsoft Online Community Support

=============== =============== =============== =====
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 26 '07 #10

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

Similar topics

2
3091
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own words, their own definitions plus an example of how the word is used in practice. It'll be all client side with - cookies? to get persistence so that the words won't disappear on me each time the page is closed (which is what happened when I
5
2757
by: Guy | last post by:
Guys Hope someone can help me! I'm having real problems getting properties I type against a control I have written at design time I have written a control by inheriting from the Button control. I am trying to add a feature whereby the control changes to a different color when the mouse floats over it, or when the button has the focus. The color changing works if the 'LightColor' is set at runtime in code. However, if I draw the control on...
0
1058
by: Andrew Baker | last post by:
I have a progress bar which is nested control and I want to persist the design time properties of this nested control. I thought all I needed to do was mark it with the DesignerSerializationVisibility.Content attribute, as below: public ProgressBar ProgressBar { get{return _progressBar;} set{_progressBar = value;}
19
2992
by: Dales | last post by:
I have a custom control that builds what we refer to as "Formlets" around some content in a page. These are basically content "wrapper" sections that are tables that have a colored header and provide an open TD with a DIV in it for the content of this formlet. (The DIV is for DHTML to hide and show the content) I've created a web page showing step by step the two problems I'm encountering. This problem is much easier to see than it...
1
1670
by: lim | last post by:
What is the possible error that occurs when the Page_load event is not triggered during execution. In my page there's some basic server control. Is there any loops holes?
0
244
by: john_teague | last post by:
I appologize for the cross-posting, but I received no responses from the building controls group. I have a custom control that inherits from a DataGrid control. I have a property that has an arraylist of strings. I want to add items as a child tag of the grid. How is the best way to do this. Here is what I have as of now.
5
4842
by: Dick | last post by:
I have a GridView bound to an ObjectDataSource. I have a Button that calls GridView.DataBind. I want the row that is selected before the DataBind to still be selected afterwards. This happens automatically if the data doesn't change. But if records have been added or deleted then it looks as if some code is necessary: I've done this by using GridView.SelectedValue to get the key value of the currently selected Row and then by itterating...
1
2093
by: David Veeneman | last post by:
I'm backporting a component to .NET 1.x, and it required me to use a custom collection, StringList, instead of List<string>. StringList is derived from CollectionBase and is marked serializable. Here's my problem: I can't get design-time property values to persist. Here is my property declaration:
1
1764
by: =?Utf-8?B?QnJldHQ=?= | last post by:
I have a basic user control that I want to localize. I created a global resource and connected up the properties I want to localize using an explicit localization expression. Everything works great, I can even see the localized text in design time when I am viewing the control. When I look at the page the control sits on at design time however I can't see the localized text. It's like the control's localization expression isn't being...
0
9699
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9562
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10536
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10304
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10285
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6838
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3792
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2966
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.