Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Creating Composite Controls ASP.NET 4.0

Creating Composite Controls ASP.NET 4.0

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelptutorial
4 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RookieCoder_NG
    wrote on last edited by
    #1

    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

    D A 2 Replies Last reply
    0
    • R RookieCoder_NG

      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

      D Offline
      D Offline
      David Mujica
      wrote on last edited by
      #2

      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:

      R 1 Reply Last reply
      0
      • D David Mujica

        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:

        R Offline
        R Offline
        RookieCoder_NG
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • R RookieCoder_NG

          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

          A Offline
          A Offline
          Ahmed Abdulrahman
          wrote on last edited by
          #4

          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 .

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups