Creating Composite Controls ASP.NET 4.0
-
Hi all, I have a requirement like this. A table has a set of say 10 fields. The user wants to search the table using any combination of fields. Instead of adding a fixed number of textboxes and labels (10),I have been thinking about creating a composite control TextBoxList..which would probably inherit from TextBox..Label..CheckBoxList. So now I ll be able to add any number of textboxes with labels by passing a parameter. I have just started reading about composite controls in asp.net 4.0. Any suggestions on how to build it would help me a lot. Thanks. P.S. My First Post Here.. :)
There is no great genius without some touch of madness - Seneca, Epistles
-
Hi all, I have a requirement like this. A table has a set of say 10 fields. The user wants to search the table using any combination of fields. Instead of adding a fixed number of textboxes and labels (10),I have been thinking about creating a composite control TextBoxList..which would probably inherit from TextBox..Label..CheckBoxList. So now I ll be able to add any number of textboxes with labels by passing a parameter. I have just started reading about composite controls in asp.net 4.0. Any suggestions on how to build it would help me a lot. Thanks. P.S. My First Post Here.. :)
There is no great genius without some touch of madness - Seneca, Epistles
Are you trying to build a "where clause" for your table? The idea would be to pick a field, pick a comparison operator (< = >), then a value and build upon it with ANDs and ORs. The result would be something like: field1 > 'A' and field2 = 100 Lots of examples on how this is done can be found on the web. Good Luck. :thumbsup:
-
Are you trying to build a "where clause" for your table? The idea would be to pick a field, pick a comparison operator (< = >), then a value and build upon it with ANDs and ORs. The result would be something like: field1 > 'A' and field2 = 100 Lots of examples on how this is done can be found on the web. Good Luck. :thumbsup:
Thanks for your interest and time. :) Yeah. I am trying to build a 'where' clause. But am not thinking about the dynamic SQL query, atleast not yet. My post was more about receiving the values to be used in the 'where' clause. Suppose I have 10 fields to be used in the 'where' clause. I would need 10 labels and 10 textboxes on the page. Instead of that, I was thinking about creating a composite control - TextBoxList (Which would be similar to a CheckBoxList control). TextBoxList would have a Label and a TextBox. So now if I add a TextBoxList to my page, design would be efficient right.? I can add any number of labels and textboxes by passing a single parameter to the control and also have them arranged automatically. I needed some suggestions on creating this TextBoxList, as I am very much a new born in the ASP.NET world. :)
There is no great genius without some touch of madness - Seneca, Epistles
-
Hi all, I have a requirement like this. A table has a set of say 10 fields. The user wants to search the table using any combination of fields. Instead of adding a fixed number of textboxes and labels (10),I have been thinking about creating a composite control TextBoxList..which would probably inherit from TextBox..Label..CheckBoxList. So now I ll be able to add any number of textboxes with labels by passing a parameter. I have just started reading about composite controls in asp.net 4.0. Any suggestions on how to build it would help me a lot. Thanks. P.S. My First Post Here.. :)
There is no great genius without some touch of madness - Seneca, Epistles
you can create c# class library in a folder (let it name be htmlhelpers) and put a method which returns a string holds the input u need like this "" and so on this method must be extension method < extension()>_ so u can use it into ur html code in the view page u just have to inherit the class u wrote and use the method which return this string .