.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
david stephan
Gaurav Pal
Post New Web Links

Custom controls and ViewState management issue

Posted By:      Posted Date: August 24, 2010    Points: 0   Category :ASP.Net


I want to know that when we create custom controls, then is there State Management through ViewState done automatically or we have to handle it explicitely ?Since i have created Custom Controls that is behaving as if it is not maintaining its state on PostBack.

View Complete Post

More Related Resource Links

Issue with Custom Controls

Hi,we are facing a page loading  problem with custom controls only IE browser. but that the same page open on mozilla firefox 3.5.  we are using all the controls on the page are custom controls. I pasted on custom control code bellow, please verify that is it written proper or not...  using System; using System.Collections.Generic; using System.ComponentModel; using System.Linq; using System.Text; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Web.UI.Design; using System.IO; using System.Configuration; using System.Web.UI.WebControls.WebParts; using System.Drawing.Design; using System.Data; namespace Ays4.Web.UI { #region class CustomizeTextBox [ToolboxData("<{0}:CustomizeTextBox runat=server></{0}:CustomizeTextBox>")] [Designer("System.Web.UI.Design.ReadWriteControlDesigner, System.Design")] [PersistChildren(true)] [ParseChildren(false)] public class CustomizeTextBox : WebControl, INamingContainer { #region Attribute private validateType.ValidationType _ValidationType = validateType.ValidationType.None; private TextBoxType.Mode _Mode = TextBoxType.Mode.None; HtmlTable mainTable; string strJs = ""; private TextBox _inputControl; strin

Maintaining viewstate on custom controls


Hi Guys,

I created a really simple control that contains a list of filter option controls in much the same way that a listbox has a list of listitems now im trying to get it to maintain the state of its children by serializing key property values of each child in to xml and putting that in to viewstate.

I've been trying to get the concept discussed here http://msdn.microsoft.com/en-us/library/ms973893.aspx which discusses the use of the interface ISerializable to work but asp.net just wont play ball ...

I'm having some trouble tring to get it to serialize in to viewstate as the serializer appears to be trying to serialize the base class properties and basically i end up with errors like - cannot serialize property "page" What do you think is my problem?

The Code:

public class FilterOption : Control, ISerializable
    public event EventHandler Checkchanged;

    CheckBox _chk = new CheckBox();
    Label _lbl = new Label();

    public string Text
        get { return _lbl.Text; }
        set { _lbl.Text = value; }

    public bool Checked
        get { return _chk.Checked; }
        set { _

Custom Controls in C# .NET

Embedding user controls in a Windows form is just like adding a simple button or text box that are already provided with .NET. These basic controls were written essentially like you code your own controls. Typically the controls you design are to be used in multiple forms or to modularize your code. These reasons help reduce the amount of code you have to type as well as make it easier for you to change your implementation. There should almost never be any reason to duplicate code because it leaves a lot of room for bugs. So, implementing functionality specific to your control in the control's source code is a good idea. This reduces code duplication as well as modularize your code, which is a good programming guideline.

Wicked Code: Craft Custom Controls for Silverlight 2


If you're unfamiliar with Windows Presentation Foundation (WPF), building that first Silverlight custom control can be a daunting experience. This article walks through the process.

Jeff Prosise

MSDN Magazine August 2008

UI on the Fly: Use the .NET Framework to Generate and Execute Custom Controls at Run Time


Creating UI controls on the fly can be accomplished via run-time code generation. And there are lots of reasons to do so. Generating these controls once and then reusing them as needed is more efficient than generating the controls each time. Read on.

Morgan Skinner

MSDN Magazine December 2005

ASP.NET 2.0: Personalize Your Portal with User Controls and Custom Web Parts


ASP.NET 2.0 introduces a Web Part control that is designed to deal with the serialization, storage, and retrieval of customization and personalization data behind the scenes. In this article, the authors explain how you can put the WebPart control to work in your ASP.NET 2.0 applications.

Ted Pattison and Fritz Onion

MSDN Magazine September 2005

Smart Cleanup: Achieve More Reliable Resource Management with Our Custom C++ Classes


Managing resources in C++ is not easy. When you're unsuccessful, your app can leak all kinds of resources including file system handles, database connections, and, of course, memory. Even in garbage-collected languages like Managed C++, resource management is difficult because garbage collection only deals with memory management, not the other resources that cause performance problems.In this article, the author describes the SmartAny template library he created, which uses a policy-based approach to dynamic resource management. Readers will learn how to use the SmartAny classes and policies to ensure the proper cleanup of their resources, be they files, OS handles, or native and unmanaged objects.

Eric Niebler

MSDN Magazine June 2003

How to add designing in Custom Controls ?


Hi ,

I am trying to create Custom control. I have created simple TextBox, Label, Buttons  etc. and added my own logic for their working,  but i want to add  some designing to that controls.I tried to add CSS file for that from the Add New Item, but there is no list for CSS. 

I added forcefully but it is not supporting CSS files.It seems that Custom controls does not support designing and layout through CSS.

Can you tell how can i polish my controls with beautiful designing and layouts ?

viewstate in a custom control

I am having issues with a simple custom control that I created by subclassing the hyperlink control.

I wanted to create a control called BackLink that would automatically grab the referring url to the page when it first loads the page. and on postbacks it would continue to use the initial value

I am able to capture and set the navigateurl property when the containing page first loads just fine but if the page submits to itself, the control loses its navigateurl value.

I have the enableviewstate property set in the aspx page but it doesn't seem to want to keep its viewstate

Am I missing something? Do I have to manage my own ViewState?

here is my code

public class BackLink : System.Web.UI.WebControls.HyperLink

public BackLink()
this.Text = "<< back";

protected override void Render(HtmlTextWriter output)
if (this.Page.IsPostBack == false)
//save back url
Uri _backUri = this.Context.Request.UrlReferrer;

if(_backUri != null) this.NavigateUrl = _backUri.PathAndQuery;

else this.NavigateUrl = "/";

Custom Search issue with freetext


Hi All,

My Environment : MOSS 2007 (sp2) with SQL Server 2005

I have a custom search webpart which uses FullTextSqlQuery to fetch the results from Index. I have a some keywords and a free text boxt to build the search query. Poeple enter their query by selecting the keywords and enter some free text into the text box.

Issue : When any PDF document (Not tested with .Doc) is searched using custom webpart with the numbers like "2,0233.21" I do not get any results returned even though the results are returned using the SharePoint out of box full text search. But when I search the content like "2+0233+21" I get results both in Out of box and in custom search webpart.

Requirement: The Custom search should be able to find the document when numbers like "2,0233.21" are entered. It should work exactly like the out of box search.

Thanks in advance for your suggestions.



Creating Custom SharePoint 2010 Field Types and Controls with Visual Studio 2010 and Silverlight 3

Learn how developers can create rich experiences in SharePoint Server 2010 publishing sites using Microsoft Silverlight 3.

Video: Creating Custom SharePoint 2010 Field Types and Controls with Visual Studio 2010 and Silverli

Watch the video that accompanies the MSDN article and learn how developers can create rich experiences in SharePoint Server 2010 publishing sites using Microsoft Silverlight 3.

Cannot set custom attributes on mobile controls in this page



I am beginner at mobile Pages with ASP.NET. And i want to make an application with contains  a few TextBox that have different size.

it's my sample code here:

<%@Page Inherits= "System.Web.UI.MobileControls.MobilePage" Language= "C# " %>
<%@ Register TagPrefix= "Mobile" Namespace= "System.Web.UI.MobileControls " Assembly= "System.Web.Mobile" %>
<Mobile:Form runat="server" id="form1" Paginate="true" >
<Mobile:Panel Paginate="True" runat=&

"Mixed mode assembly is built against version 'v2.0.50727'.... " issue and use custom config file

Hi, My Winform applilcation has used Microsoft.SqlServer.Management.Common namespace(assembly :Microsoft.Sqlserver.smo.dll/Microsoft.Sqlserver.ConnectionInfo.dll) and developed in .NET 4.0. Problem:Application is throw an exception when it tries to use above assembly reference methods. Full error text is shown below, "Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information. " Error is resolved when we include "app.config" file with below code, <?xml version="1.0"?> <configuration> <startup useLegacyV2RuntimeActivationPolicy="true"> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/> </startup> </configuration> But, I need to keep configuration file as "renamed.config" and not to include app.config file as of the project requirement.I have set configuration file as "renamed.config" file using below code, //AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE", "d:\\reanmed.config" ); I have also included <Startup> element in this "renamed.config" configuration file and removed the app.config file.But it raise me below error, it always expect app.config file with <Startup> element to resolve this iss

Calculated measures, calculated cells, and custom rollups issue

Hi,  I'm a little bit confused according to the purpose of Calculated measures, calculated cells, and custom rollups as they lead practically to the same goal, is there any differnce between those modes from a technical point of view. And for the last one, the custom roll up the question how to perform this, I need a walkthrough that lead me to undersand the way to set a custom roll up to a given dimesion, I visited microsoft site but the inforamtion that I have is poor, so is there any other source that exposes that as a step by step example? Thank youThe complexity resides in the simplicity

Issue with custom Redirect PageLayout

Hi, I have duplicated RedirectPageLayout.aspx to create custom redirect page layout. In my custom redirect page layout, i have linked my custom content type.  From my root website, when I try to create redirect page from my custom redirect page layout, in a edit mode it shows Redirect URL control to get the URL to redirect. But from any sub site, when I try to create redirect page from my custom redirect page layout, in a edit mode it doesn't show "Redirect URL" control to get the URL to redirect. Please let me know about how to fix this. or let me know some alternative way to do it. Regards, Prakashwww.aristonsoft.com - .net 3.5 hosting provider in India
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend