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