| | |
How to Dynamically get All controls (and it’s IDs) in an aspx Page?
Please support our C# advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2009
Posts: 1
Reputation:
Solved Threads: 0
HEllo, I need to dynamically activate fields in a page according to the service that is going to be executed...
Let me explain:
There's a page with all the possible fields and a ListBox with all the selected services to be executed, then when the user selects which service to execute (change a car plate, for example), then I need to activate only the field(s) that the service require... (The realationship between Services and Fields are stored in a database).
Note that busExecutaServico is the class which contains the method (EnableField) for checking if the selected item matches any field on the database..
I can't seem to get the control.ID.ToString() to work properly (the ID always comes as NULL)
If anyone can help me solve this, or if there's another way (even if it's completely different from what i'm trying), it would be of great help. thanks
Let me explain:
There's a page with all the possible fields and a ListBox with all the selected services to be executed, then when the user selects which service to execute (change a car plate, for example), then I need to activate only the field(s) that the service require... (The realationship between Services and Fields are stored in a database).
C# Syntax (Toggle Plain Text)
public void CheckAll(int pService_Id, Control pPage) { foreach (Control control in pPage.Controls) { busExecutaServico vExecuta = new busExecutaServico(); if (vExecuta.EnableField(control.ID.ToString(), Convert.ToInt32(listBoxServices.SelectedValue))) { switch (control.GetType().ToString()) { case "TextBox": TextBox controleText = (TextBox)Page.FindControl(control.ID.ToString()); controleText.Enabled = true; break;
Note that busExecutaServico is the class which contains the method (EnableField) for checking if the selected item matches any field on the database..
I can't seem to get the control.ID.ToString() to work properly (the ID always comes as NULL)
If anyone can help me solve this, or if there's another way (even if it's completely different from what i'm trying), it would be of great help. thanks
You may need this question in ASP.NET forum http://www.daniweb.com/forums/forum18.html they will help you more I have no more than recommending you to debug and discover why Null comes...
BI Developer | LINKdotNET
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
B.Sc Computer Science, Helwan University
Technical blog | http://ramymahrous.wordpress.com
LinkedIn | http://www.linkedin.com/in/ramymahrous
![]() |
Similar Threads
- show aspx page or dynamic contents in Silverlight xaml page (ASP.NET)
- how to make the aspx page at runtime (ASP.NET)
- Create .aspx page at runtime (ASP.NET)
- Webform - Loading an aspx page within a page (ASP.NET)
- How to Enable and disable controls in .aspx page using javascript? (JavaScript / DHTML / AJAX)
- Problem in Redirecting a .aspx Page (ASP.NET)
- create aspx page in runtime (C#)
Other Threads in the C# Forum
- Previous Thread: length in mp3 player
- Next Thread: Gabor Filter in C# (For Image Processing)
| Thread Tools | Search this Thread |
.net access ado.net algorithm array barchart bitmap box broadcast buttons c# chat check checkbox client color combobox concurrency control conversion csharp custom database datagrid datagridview dataset datetime degrees development draganddrop drawing encryption enum event excel file files form format forms function gdi+ globalization httpwebrequest image index input install java label list listbox listener mandelbrot math microsoftc#visualexpress mouseclick mysql networking operator path photoshop picturebox pixelinversion post prime programming radians regex remote remoting richtextbox save saving serialization server sleep socket sql statistics stream string table tcp text textbox thread time timer treeview update usercontrol validation view visualstudio webbrowser windows winforms wpf xml






