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. How to call a web user control through C#?

How to call a web user control through C#?

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nettutorialquestion
5 Posts 2 Posters 0 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.
  • A Offline
    A Offline
    Affan Toor
    wrote on last edited by
    #1

    Hi every one! my application is in ASP.NET/C# 2005. I want to call a web user control from C# code and display it on a specific location on page. is it possible? also is it possible to set values in controls of user control from the page where it is called? Actually i want to display a table having different controls, X number of times depending on count of files in a folder and also set their values dynamically. should i use user control for this? if yes then how? and if no then what else could be used? Regards, Affan Ahmad Toor

    .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

    C 1 Reply Last reply
    0
    • A Affan Toor

      Hi every one! my application is in ASP.NET/C# 2005. I want to call a web user control from C# code and display it on a specific location on page. is it possible? also is it possible to set values in controls of user control from the page where it is called? Actually i want to display a table having different controls, X number of times depending on count of files in a folder and also set their values dynamically. should i use user control for this? if yes then how? and if no then what else could be used? Regards, Affan Ahmad Toor

      .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      Of course. Your user control is a member variable of the code behind class - do what you want with it. You'd have to use CSS to position it precisely on the page.

      Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

      A 1 Reply Last reply
      0
      • C Christian Graus

        Of course. Your user control is a member variable of the code behind class - do what you want with it. You'd have to use CSS to position it precisely on the page.

        Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

        A Offline
        A Offline
        Affan Toor
        wrote on last edited by
        #3

        Thanks for reply... My user control contains link buttons and labels, i want to pass the text and URL to link buttons/labels dynamically. is it possible? and how? i googled but could not find any help. Thanks in advance... Regards, Affan Ahmad Toor

        .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

        C 1 Reply Last reply
        0
        • A Affan Toor

          Thanks for reply... My user control contains link buttons and labels, i want to pass the text and URL to link buttons/labels dynamically. is it possible? and how? i googled but could not find any help. Thanks in advance... Regards, Affan Ahmad Toor

          .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

          C Offline
          C Offline
          Christian Graus
          wrote on last edited by
          #4

          I recommend you buy a basic book on object oriented programming in whatever language you're using, and read it. As I said, your control is a member of your class, you can access it's methods and properties from there. Don't make your controls public tho, just expose the properties you want to set, such as the text.

          Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

          A 1 Reply Last reply
          0
          • C Christian Graus

            I recommend you buy a basic book on object oriented programming in whatever language you're using, and read it. As I said, your control is a member of your class, you can access it's methods and properties from there. Don't make your controls public tho, just expose the properties you want to set, such as the text.

            Christian Graus - Microsoft MVP - C++ "also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )

            A Offline
            A Offline
            Affan Toor
            wrote on last edited by
            #5

            Thanks for reply, i got your point, this part of problem is solved. but one problem is stil there...how can i call user control using C# code? as i mentioned earlier that i want to decide at runtime that how many time user control must be displayed, so how can i do it? only method i know is to add it in page using HTML code like: "" can i do it on page load within a loop, using C# code? Regards, Affan Ahmad Toor .................. QUAIDIAN FOR ONCE, QUAIDIAN FOR EVER!

            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