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. Changing the properties of control used in Web User Control from Web Form

Changing the properties of control used in Web User Control from Web Form

Scheduled Pinned Locked Moved ASP.NET
asp-netcomquestion
5 Posts 4 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.
  • D Offline
    D Offline
    Dhyanga
    wrote on last edited by
    #1

    i have designed one Web user control say there is button1 and button2(both button1 and button2 are visible true here).I also have taken two Web Forms say Form1 and Form. In these both forms, i want to use the Web user control i have mentioned above.But in form1, i want button1 visible true and button2 visible false.Similary in form2, i want button1 visible false and button2 visible true. Is it possible to do that using one web user control ? Or should i have to take seperate web user control ?? Currently i am using Dot Net 2005.

    suchitamanandhar@hotmail.com

    S R 2 Replies Last reply
    0
    • D Dhyanga

      i have designed one Web user control say there is button1 and button2(both button1 and button2 are visible true here).I also have taken two Web Forms say Form1 and Form. In these both forms, i want to use the Web user control i have mentioned above.But in form1, i want button1 visible true and button2 visible false.Similary in form2, i want button1 visible false and button2 visible true. Is it possible to do that using one web user control ? Or should i have to take seperate web user control ?? Currently i am using Dot Net 2005.

      suchitamanandhar@hotmail.com

      S Offline
      S Offline
      Sandeep Akhare
      wrote on last edited by
      #2

      Yes you can have single form for the both depending on requirement you change the Page Rules.

      Thanks and Regards Sandeep If If you look at what you do not have in life, you don't have anything, If you look at what you have in life, you have everything... "

      1 Reply Last reply
      0
      • D Dhyanga

        i have designed one Web user control say there is button1 and button2(both button1 and button2 are visible true here).I also have taken two Web Forms say Form1 and Form. In these both forms, i want to use the Web user control i have mentioned above.But in form1, i want button1 visible true and button2 visible false.Similary in form2, i want button1 visible false and button2 visible true. Is it possible to do that using one web user control ? Or should i have to take seperate web user control ?? Currently i am using Dot Net 2005.

        suchitamanandhar@hotmail.com

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

        If I understand your question correctly, the answer is yes, you can implement that in a single webusercontrol. On your webusercontrol (the one that contains button1 and button2), you need to provide a public property to get/set the Visible property of the buttons. For example to have a publicly-accessible Visible property of button1, you may provide this code in your webusercontrol's codebehind: public bool ButtonOneVisible { get{return button1.Visible;} set{button1.Visible = value;} } You can provide similar approach for button2. Now, on Form1's codebehind, you only need to set the value of this property to true/false depending on your need. For example, on the codebehind of Form1.aspx: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebUserControl1.ButtonOneVisible = true; WebUserControl1.ButtonTwoVisible = false; } }

        [http://www.theunix.info/sheijin\]
        Remember, your work is not yours alone. Somewhere, there are some codes written by others amongst us that depends on your work. By failing to see that you are part of their ecosystem, you are bound to break their code.

        M 1 Reply Last reply
        0
        • R randz

          If I understand your question correctly, the answer is yes, you can implement that in a single webusercontrol. On your webusercontrol (the one that contains button1 and button2), you need to provide a public property to get/set the Visible property of the buttons. For example to have a publicly-accessible Visible property of button1, you may provide this code in your webusercontrol's codebehind: public bool ButtonOneVisible { get{return button1.Visible;} set{button1.Visible = value;} } You can provide similar approach for button2. Now, on Form1's codebehind, you only need to set the value of this property to true/false depending on your need. For example, on the codebehind of Form1.aspx: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { WebUserControl1.ButtonOneVisible = true; WebUserControl1.ButtonTwoVisible = false; } }

          [http://www.theunix.info/sheijin\]
          Remember, your work is not yours alone. Somewhere, there are some codes written by others amongst us that depends on your work. By failing to see that you are part of their ecosystem, you are bound to break their code.

          M Offline
          M Offline
          mani_iips
          wrote on last edited by
          #4

          "Randz" answered what i was gng to write. Thats the best way for doing the required job. BUt i hope u understand the consequence of making a control's (visible=false), setting this property to false "stops" a control being rendered. That is, it wont be available to client side (javascript also).

          R 1 Reply Last reply
          0
          • M mani_iips

            "Randz" answered what i was gng to write. Thats the best way for doing the required job. BUt i hope u understand the consequence of making a control's (visible=false), setting this property to false "stops" a control being rendered. That is, it wont be available to client side (javascript also).

            R Offline
            R Offline
            randz
            wrote on last edited by
            #5

            that is true. thanks for the emphasis.

            [http://www.theunix.info/sheijin\]
            Remember, your work is not yours alone. Somewhere, there are some codes written by others amongst us that depends on your work. By failing to see that you are part of their ecosystem, you are bound to break their code.

            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