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

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

Retrieve Forms' Controls' ID from separate class

Posted By:      Posted Date: October 21, 2010    Points: 0   Category :ASP.Net


i am using VS2008 and SQL Server 2005. i have the following project architecture:

i have around 60 pages in various directory within the project. i have stored all the page names(eg: Default.aspx, EmpSetup.aspx, Order.aspx, etc) in the DB and also i have retrieved the page names one-by-one from the DB.

my issue is to retrieve the Form's all Control IDs one by one within a loop. For example, i need to get the IDs of Default.aspx Form's Control IDs in first loop, then the 2nd page, etc. but as i have only the Page names - not the page's instance so it becomes hard for me to read the IDs. i can not use the FindControl() method as i don't know which page has what controls. Total scenario is dynamic.

is there anyone who can give me some light or code snippets to overcome this issue?

View Complete Post

More Related Resource Links

How to programmatically add controls to Windows forms at run time by using Visual C#

Create a Windows Forms Application
Start Visual Studio .NET or Visual Studio 2005 or a later version, and create a new Visual C# Windows Application project named WinControls. Form1 is added to the project by default.
Double-click Form1 to create and view the Form1_Load event procedure.
Add private instance variables to the Form1 class to work with common Windows controls. The Form1 class starts as follows:

Text Rendering: Build World-Ready Apps Using Complex Scripts In Windows Forms Controls


The System.Windows.Forms.TextRenderer class provides support for complex scripts in Windows Forms controls so you can render text the way you want and support international locales.

Miguel A. Lacouture

MSDN Magazine March 2006

Visual Studio .NET: Building Windows Forms Controls and Components with Rich Design-Time Features, P


This is the second of two articles discussing the extremely rich design-time features of the .NET Framework. Part 1 discussed the basics, showing you where to start and how to extend your control implementation through attributes and interfaces, as well as their effects on the property browser, code serialization, and other controls. Part 2 continues the journey by concentrating on design-time functionality that you can implement beyond your components and controls, including TypeConverters, UITypeEditors, and Designers. It would be impossible to cover everything you can do in two short articles, which is a testament to just how all-encompassing and flexible the design-time capability of the .NET Framework is.

Michael Weinhardt and Chris Sells

MSDN Magazine May 2003

Advanced Basics: Windows Forms Controls


Build a control that allows the user to drag and drop other controls onto the new control at run time, and allow the user to move the control around on a form, all in Visual Basic.

Ken Spencer

MSDN Magazine May 2003

Visual Studio .NET: Building Windows Forms Controls and Components with Rich Design-Time Features


Visual Studio .NET provides support for designing rich features into your controls and components, allowing you to set properties, set form placement, inherit from base classes, and much more. So how does Visual Studio .NET do all this? What does the Windows Forms designer do? What's the difference between a control and a component? How does Visual Studio integrate your controls so that they can access features of the .NET Framework?In this article, the authors answer these common questions by building a clock control and taking the reader along for the ride. In building the control, hosts and containers are illustrated, the property browser is explained, debugging is discussed, and a general overview of the design-time infrastructure is presented.

Michael Weinhardt and Chris Sells

MSDN Magazine April 2003

Windows Forms: Developing Compelling User Controls that Target Forms in the .NET Framework


In the beginning, writing controls meant dealing with Windows messages. Then came Visual Basic controls, which introduced methods, properties, and events. Later, ActiveX controls, which ran atop COM, became popular. While each innovation in control writing brought more flexibility, nothing has matched the versatility of the new .NET Windows Forms controls and Web Forms controls. This article, the first of a two-part series, introduces the reader to Windows Forms, beginning with their inheritance from one of the .NET CLR base classes, which makes control creation much faster than before. Control programming is illustrated through the development of a login control. The equally flexible Web Forms controls will be covered in Part 2.

David S. Platt

MSDN Magazine April 2002

Windows Forms/Web Controls Naming Convention


Has Microsoft documented on the naming convention for windows and web controls like they did for Classes.


Problem getting values next to each other from two separate CheckBoxList controls

Hi, I am using three CheckBoxList controls in ASP.NET Wizard control. CheckBoxList controls: <asp:CheckBoxList ID="cblLondonDates" runat="server" DataSourceID="SqlDataSource1" DataTextField="ShowDate" DataTextFormatString="{0:G}" DataValueField="ShowDate" ForeColor="#333333" CssClass="ShowDateMargin"></asp:CheckBoxList> <asp:CheckBoxList ID="cblSingleL" runat="server" DataSourceID="SqlDataSource2" DataTextField="size8" DataValueField="size8" ForeColor="#333333"> </asp:CheckBoxList> <asp:CheckBoxList ID="cblHalfL" runat="server" DataSourceID="SqlDataSource2" DataTextField="size6" DataValueField="size6" ForeColor="#333333"></asp:CheckBoxList>   cblLondonDates chackboxlist control shows dates generated from SQL table. cblSingleL an cblHalfL show table sizes. On ASP page they come up as following: 12/03/2011(checkboxlist-ID="cblLondonDates")-Single(checkboxlist-ID="cblSingleL") - Half(checkboxlist-ID="cblHalfL") 03/03/2012(checkboxlist-ID="cblLondonDates")-Single(checkboxlist-ID="cblSingleL") - Half(checkboxlist-ID="cblHalfL") 05/10/2010(checkboxlist-ID="cblLo

Cannot retrieve values of dynamically generated controls

Hi All, I am creating a user control which contains checkboxes and labels that needs to be created on fly. The dynamic generation of these controls depend on the values retreived from a SPlist. I have several panels that display items queried from the list on the basis of a selection criteria. On a button click event I need to capture all the selected values from the controls that were generated dynamically.  When I traverse each dynamic control that I added to the panel, I dont see their values. I tried using recursive retrieval of the control from the page as well but it just behaves crazy, it treats a radio button as a checkbox and returns a value that I am not looking for. I am not using the the page_load() or any other event, I use the button handler on my custom method. I was thinking for ViewState, ControlsState or SessionState. I assume ViewState may not work on this as the dynamically generated controls need to be in the page_load event. Please guide as this getting way more complicated than what I had ever thought of it to be.

Retrieve Dynamically Created Controls

I am building a webform dynamically but when I go to get the values the placeholder has no controls.  Every control added has an unique ID.  Does anyone know what I am doing wrong (language is C#).      aspx page <asp:UpdatePanel ID="upShoppingCart" runat="server" UpdateMode="Conditional" >                    <ContentTemplate>                        <asp:PlaceHolder ID="phShoppingCart" runat="server" />                        <br /><asp:Button ID="btnUpdateCart" runat="server" Text="Update" OnClick="btnUpdateCart_OnClick" />                    </ContentTemplate>                </asp:UpdatePanel>   .cs page         private void CreateShoppingCart()     &nb

spmetal generated class and content type (for page layout) retrieve problem


I'm working with a console application to generate my sites and subsites (hierarchy). And i've got a problem with a generated spmetal class.


this doesn't work:


static void Main(string[] args)


            string SITE = string.Concat("http://"Environment.MachineName);         



Get username according to userid & use username on separate web forms in website ?


hi to all . i 'm creating a website. i create a login form. after login my session will be start and all page of user profile will check first is session istart. i have stored userid in session for identify user. But i want to username of that userid. Remaiber username and userid are different. and i want to show only username on welcome tab. 

e.g.  userid= rksaini89

       username= ramkrishn

so i want to show like this "welcome ramkrishn" on my home page and other many places on different forms.

my confusion is that how to get username acording userid and where to keep store it. 

i can get it from database according session but i'm confused where to keep it so i can use it everywhere on my website...??

Adding windows forms controls to the display of list items



I'm new to Sharepoint development, and was wondering if I could get some brief pointers to get me going in the right direction.  I'm required to add a button to list items that on submit does some manipulation of the data in the fields inside the item and then sends that data off to an external webservice.  The complexity is sufficient to warrant managed code, i.e. C#.

What I'd like to know is how to approach integrating this code into Sharepoint.  I've read about web parts, but viewing list items doesn't involve web part pages on my installation so I can't include my own.  What other ways are there of doing this?

Cheers all

Exposing Windows Forms as ActiveX controls



We need support for the following problem. We have an application implemented in .NET (C# language) technology.

This is a Windows Forms application using a MDI (multiple document interface) style. We are trying to expose the

whole application as an ActiveX control in order to be integrated into a Java-based user interface.

It seems that this is not possible because:

-          A Multiple-document interface (MDI) parent form must be a top-level window [1].

-          Top-level Windows Forms control cannot be exposed

Separate class library for controllers,models,repositories,business logic


Alright after scratching my mind for a while.. I still cant figure out how to go ahead with my architecture: http://forums.asp.net/p/1618613/4149672.aspx#4149672

nor i can find a decent link / info on it...So, iam goin to give this one more try.
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