I am a beginner in asp.net(C#) and stuck in an important point.
I have a dropdown list on my homepage which users select a category.
After selecting the category, user will fill a form which has related controls to that category in it.
As I have many categories, I just want to have single ascx page and adding controls to it dynamically according to the user choice.
For example: One chose Telephone category, he will face a form having drop down lists asking, what brand? what color?
And one chose, book category, he will face drop down lists asking which type? howmany pages?
So 1 ascx must do my work at runtime done as I have alot of categories.
I am going to take these criterias from a database table which has CategoryID and Criteria colomns.
And if I can do that, will it be possible to add field validators to these dynamically created controls.
Nearly all controls are drop down list, if this helps.
Any help would be highly appreciated..
Thanks alot
You can add an asp:placeholder Or literal control to your page and then populate all the controls programatically. Altough you will have to take special care to make sure the control state and view state are correct at all times.
Here's an example on how to do it
https://web.archive.org/web/20211020131055/https://www.4guysfromrolla.com/articles/081402-1.aspx
Related
I'm trying to create a form that operates like the Visual Studio Properties page, with a list of categories (like Application, Build, Build Events etc) in a column on the left and corresponding information on the right. I'm planning to use either panels or a tabcontrol (with the tab header hidden) for the right hand side.
However, I'm unsure how best to create the column of categories on the left. Is there a standard control that provides this functionality?
Otherwise, I considered using a panel containing Buttons, or individual Panels, or a ListBox, but I don't think these would give the same look. Also, I don't want to write code if a suitable control already exists.
Ideally I would like to be able to easily disable all the categories, for example while editing a record on one page.
Having nested categories might be nice, but is not essential.
If the information on the right is not related to one another as you switch categories on the left, to create a good separation between categories I'd suggest you do the following:
Create a user control for each individual category
Split your form in two, the bar on the left and a panel on the right
The bar on the left, for the categories, can be a list of radio buttons, or links, or whatever you like. I'd suggest a TreeView since it easily support sub-categories.
As the user click on a category (by attaching a method to the corresponding even on the control used for the categories) you can remove the control from the panel, if any, and reset the control that corresponds to the selected category.
I have one table in a de-normalized form Named 'Category Classification' in which i have 4 fields like Category, Subcategory, Brand and Company.
I want to develop a searching criteria on asp.net in which the scenario would be:
If i select category from the drop down, It should automatically show the subcategories associated with that selected category in the next drop down of the subcategory.
Same goes for the brand as well. If i select the subcategory, The grid should appear with the check boxes of the related brands of that selected subcategory.
The screen shot of the said criteria is attached along.
I need the logic behind the denormalized database like Microsoft excel has that functionality which i need to implement on asp.net.
Your help would be highly appreciated.
To achieve the linked drop down lists goal, here is a link that explains the issue in details and solve it without using Jquery and Ajax
Creating Cascading DropDownLists is ASP.Net
I have a page with around 20+ controls. Within this page I have a partial View which I am using to create an editable grid. This grid has Add New Row/Remove Row buttons on click of which data entered in the textboxes in grid row gets added to the grid.
Whenever I click these 2 buttons, my page is getting refreshed due to which whatever data is being entered by the user in the 20+ controls of main page is lost.
I have tried hopelessly searching for solutions quite some time, but still trying my luck out here. Any ideas are appreciated.
Well I recommend you to use full jquery mechanisms to add or remove rows. You can easily add or remove HTML elements. All you have to care about is to maintain the numbering system. I suggest you to use a view model that contains a list of objects that you need to add or remove. At first render it normally by providing list of objects (from database or other source, if required). After this define your add and remove buttons to type button and play with jquery to add remove table rows or even divs. After adding or removing required element, reorganize your numbering. At submit you can use either full postback or ajax postback. If Any confusion, let me know.
I am facing weird kinda situation. I have form which consists of 6 Fields among which 1 is drop down list. Now i have filled that drop down from another table but problem is that the Drop Down consists loads many items (ComplaintID) and can extent further. So what can be the solution instead of using Drop down or trimming it or anything.
have you tried a listbox? that lets you scroll so doesn't matter how many items really
Have a look at
Chosen
Autocomplete
Also have a look at
Why drop-down lists are bad for the user experience?
What are the alternatives to a very long dropdown?
Alternatives to huge drop down lists
(C#/SQL/Approach-question)
This has to be one of the hardest nuts I've ever had to crack. So I sincerely hope one of you smart people out there have tried to solve this before! :)
I have a much of categories (A,B,C) with pictures.
For each picture I need to ascribe some information, based on some controls that have either no- or predefined options. For instance in category A I have a textbox where you can enter anything you want, and a dropdownbox where you can choose between 3 options.
Now, for each category I would like to be able to design (decide) which controls (text, select, checkbox, radio, etc.) I want to ascribe to a category, and I want also to be able to decide what values apply to that control. Let's say I have a select-control, and I want to be able to decide if multiple select are allowed, and which values are available.
So the end product would be:
I can administrate what categories have which controls in them, and which options are available (i.e. single or multiple select) as well as which values are ascribed or allowed.
I need to be able to store this information in a persistable fashion.
I need to be able to "easily" parse the return-data from the page where the controls are rendered.
I realize this is a complicated question, and I will be happy to answer any questions you might have to help clarify the problem.
Thank you in advance!
You could separate the render part (dynamically generated) apart from what to render(based on categories).
Assuming you will use winform controls.. you could have a config file or a simple SQL table that follows schema below:
Table_Category (CategoryName, nickNameOfControl, NotNull, OtherAttributes)
Table_Control (nickNameOfControl, ControlType, Values)
Based on your actual table design, you will be able to CRUD on the tables design time for administration, your render part of the program can read the ControlType information (TextBox, ComboBox etc) and dynamically generate the controls at run time.
Hope this helps.