Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx thread: User Controls


Message #1 by "Douglas Rohm" <drohm@a...> on Sun, 10 Mar 2002 17:18:57 -0500
Hi all,

I'm using user controls for my site and want to know if its possible to

set the values of properties of of the user controls through the main

.aspx page.  For example.  I have a label in the user control.  I made a

public property for the user control but can't seem to figure out how to

set the value of the property from the main .aspx page.  Any help would

be great.



Doug





Message #2 by Scott Mitchell <mitchell@4...> on Sun, 10 Mar 2002 16:59:06 -0800
Here's how you could do it, assuming your user control was setup to

have a TagPrevix of bleh and a TagName of blah:



<bleh:blah runat="server" id="myUserControl"

PropertyName="PropertyValue" />



or you could do it like:



<bleh:blah runat="server" id="myUserControl" />



<script runat="server" language="VB">

  Sub Page_Load(sender as Object, e as EventArgs)

    myUserControl.PropertyName = PropertyValue 'where PropertyValue is

of the right type

  End Sub

</script>



hth



    Scott Mitchell

    mitchell@4...





***********************************************************



Looking to learn ASP.NET?  Look no further than:



   Sams Teach Yourself ASP.NET in 21 Days

   http://www.amazon.com/exec/obidos/ASIN/0672321688/4guysfromrollaco



***********************************************************



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 2:19 PM

| To: ASP+

| Subject: [aspx] User Controls

|

|

| Hi all,

| I'm using user controls for my site and want to know if its

| possible to

| set the values of properties of of the user controls

| through the main

| .aspx page.  For example.  I have a label in the user

| control.  I made a

| public property for the user control but can't seem to

| figure out how to

| set the value of the property from the main .aspx page.

| Any help would

| be great.

|

| Doug

|

|

|




| $subst('Email.Unsub').



Message #3 by "Douglas Rohm" <drohm@a...> on Sun, 10 Mar 2002 20:38:59 -0500
Thanks Scott.  How about if you have this setup.  I have a main .aspx

page and on that page I have two user controls.  Can one of the user

controls get/set properties on the other user control and vice versa

from within the user control?  



Doug



-----Original Message-----

From: Scott Mitchell [mailto:mitchell@4...] 

Sent: Sunday, March 10, 2002 7:59 PM

To: ASP+

Subject: [aspx] RE: User Controls





Here's how you could do it, assuming your user control was setup to have

a TagPrevix of bleh and a TagName of blah:



<bleh:blah runat="server" id="myUserControl"

PropertyName="PropertyValue" />



or you could do it like:



<bleh:blah runat="server" id="myUserControl" />



<script runat="server" language="VB">

  Sub Page_Load(sender as Object, e as EventArgs)

    myUserControl.PropertyName = PropertyValue 'where PropertyValue is

of the right type

  End Sub

</script>



hth



    Scott Mitchell

    mitchell@4...





***********************************************************



Looking to learn ASP.NET?  Look no further than:



   Sams Teach Yourself ASP.NET in 21 Days

   http://www.amazon.com/exec/obidos/ASIN/0672321688/4guysfromrollaco



***********************************************************



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 2:19 PM

| To: ASP+

| Subject: [aspx] User Controls

|

|

| Hi all,

| I'm using user controls for my site and want to know if its possible 

| to set the values of properties of of the user controls

| through the main

| .aspx page.  For example.  I have a label in the user

| control.  I made a

| public property for the user control but can't seem to

| figure out how to

| set the value of the property from the main .aspx page.

| Any help would

| be great.

|

| Doug

|

|

|

| ---

| Change your mail options at http://p2p.wrox.com/manager.asp or to 

| unsubscribe send a blank email to $subst('Email.Unsub').












Message #4 by Scott Mitchell <mitchell@4...> on Sun, 10 Mar 2002 17:47:02 -0800
Why do you want to do this?  Think of a User control as a black-box.

You should be able to use them on any page, and the user control

shouldn't care what other user controls are or aren't present.  If you

try to get user controls to affect other user control's properties you

are violating this model.



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 5:39 PM

| To: ASP+

| Subject: [aspx] RE: User Controls

|

|

| Thanks Scott.  How about if you have this setup.  I have a

| main .aspx

| page and on that page I have two user controls.  Can one of the user

| controls get/set properties on the other user control and vice versa

| from within the user control?

|

| Doug

|

| -----Original Message-----

| From: Scott Mitchell [mailto:mitchell@4...]

| Sent: Sunday, March 10, 2002 7:59 PM

| To: ASP+

| Subject: [aspx] RE: User Controls

|

|

| Here's how you could do it, assuming your user control was

| setup to have

| a TagPrevix of bleh and a TagName of blah:

|

| <bleh:blah runat="server" id="myUserControl"

| PropertyName="PropertyValue" />

|

| or you could do it like:

|

| <bleh:blah runat="server" id="myUserControl" />

|

| <script runat="server" language="VB">

|   Sub Page_Load(sender as Object, e as EventArgs)

|     myUserControl.PropertyName = PropertyValue 'where

| PropertyValue is

| of the right type

|   End Sub

| </script>

|

| hth

|

|     Scott Mitchell

|     mitchell@4...

|

|

| ***********************************************************

|

| Looking to learn ASP.NET?  Look no further than:

|

|    Sams Teach Yourself ASP.NET in 21 Days

|

http://www.amazon.com/exec/obidos/ASIN/0672321688/4guysfromrollaco



***********************************************************



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 2:19 PM

| To: ASP+

| Subject: [aspx] User Controls

|

|

| Hi all,

| I'm using user controls for my site and want to know if its possible

| to set the values of properties of of the user controls

| through the main

| .aspx page.  For example.  I have a label in the user

| control.  I made a

| public property for the user control but can't seem to

| figure out how to

| set the value of the property from the main .aspx page.

| Any help would

| be great.

|

| Doug

|

|

|

| ---

| Change your mail options at http://p2p.wrox.com/manager.asp or to

| unsubscribe send a blank email to $subst('Email.Unsub').



















Message #5 by "Douglas Rohm" <drohm@a...> on Sun, 10 Mar 2002 20:59:38 -0500
I see your point.  I've made adjustments already and have my pages

working, I was just wondering if it were possible.



I'm building a forms-based authentication app that has the main .aspx

page with a header user control and I also made the form into a user

control.  I was trying to get the form user control to set certain

properties for the header user control based on if the user successfully

logged in or not.  I just realized though, that I shouldn't make the

login form a user control. I should make it into a custom server control

instead.  Then, from within my header user control, I could get the

value of a property in the login server control. In my header user

control, I'd like to set a label to display "Login" if they are not

logged in or "Logout" if they are logged in.  I'd also like to get the

user's first name to display it in another label in the header user

control. (hope this makes sense).



I think creating a custom server control for the login control makes

more sense.  What do you think?



Doug



-----Original Message-----

From: Scott Mitchell [mailto:mitchell@4...] 

Sent: Sunday, March 10, 2002 8:47 PM

To: ASP+

Subject: [aspx] RE: User Controls





Why do you want to do this?  Think of a User control as a black-box. You

should be able to use them on any page, and the user control shouldn't

care what other user controls are or aren't present.  If you try to get

user controls to affect other user control's properties you are

violating this model.



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 5:39 PM

| To: ASP+

| Subject: [aspx] RE: User Controls

|

|

| Thanks Scott.  How about if you have this setup.  I have a main .aspx

| page and on that page I have two user controls.  Can one of the user

| controls get/set properties on the other user control and vice versa

| from within the user control?

|

| Doug

|

| -----Original Message-----

| From: Scott Mitchell [mailto:mitchell@4...]

| Sent: Sunday, March 10, 2002 7:59 PM

| To: ASP+

| Subject: [aspx] RE: User Controls

|

|

| Here's how you could do it, assuming your user control was setup to 

| have a TagPrevix of bleh and a TagName of blah:

|

| <bleh:blah runat="server" id="myUserControl" 

| PropertyName="PropertyValue" />

|

| or you could do it like:

|

| <bleh:blah runat="server" id="myUserControl" />

|

| <script runat="server" language="VB">

|   Sub Page_Load(sender as Object, e as EventArgs)

|     myUserControl.PropertyName = PropertyValue 'where PropertyValue is

| of the right type

|   End Sub

| </script>

|

| hth

|

|     Scott Mitchell

|     mitchell@4...

|

|

| ***********************************************************

|

| Looking to learn ASP.NET?  Look no further than:

|

|    Sams Teach Yourself ASP.NET in 21 Days

|

http://www.amazon.com/exec/obidos/ASIN/0672321688/4guysfromrollaco



***********************************************************



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 2:19 PM

| To: ASP+

| Subject: [aspx] User Controls

|

|

| Hi all,

| I'm using user controls for my site and want to know if its possible 

| to set the values of properties of of the user controls through the 

| main .aspx page.  For example.  I have a label in the user

| control.  I made a

| public property for the user control but can't seem to

| figure out how to

| set the value of the property from the main .aspx page.

| Any help would

| be great.

|

| Doug

|

|

|

| ---

| Change your mail options at http://p2p.wrox.com/manager.asp or to 

| unsubscribe send a blank email to $subst('Email.Unsub').





---

Change your mail options at http://p2p.wrox.com/manager.asp or to

unsubscribe send a blank email to $subst('Email.Unsub').







---

Change your mail options at http://p2p.wrox.com/manager.asp or to

unsubscribe send a blank email to $subst('Email.Unsub').












Message #6 by "McCloy, Russell" <Russell.McCloy@B...> on Mon, 11 Mar 2002 13:20:10 +1100
hello all,



Im trying to do the same thing. I have a logon user control with 2

properties.

One for password and one for username.



Should I be using a custom server control instead.

In actual fact, I don't know the difference.

Can someone explain.



thanks



RuSs



-----Original Message-----

From: Douglas Rohm [mailto:drohm@a...]

Sent: Monday, 11 March 2002 1:00 PM

To: ASP+

Subject: [aspx] RE: User Controls





I see your point.  I've made adjustments already and have my pages

working, I was just wondering if it were possible.



I'm building a forms-based authentication app that has the main .aspx

page with a header user control and I also made the form into a user

control.  I was trying to get the form user control to set certain

properties for the header user control based on if the user successfully

logged in or not.  I just realized though, that I shouldn't make the

login form a user control. I should make it into a custom server control

instead.  Then, from within my header user control, I could get the

value of a property in the login server control. In my header user

control, I'd like to set a label to display "Login" if they are not

logged in or "Logout" if they are logged in.  I'd also like to get the

user's first name to display it in another label in the header user

control. (hope this makes sense).



I think creating a custom server control for the login control makes

more sense.  What do you think?



Doug



-----Original Message-----

From: Scott Mitchell [mailto:mitchell@4...] 

Sent: Sunday, March 10, 2002 8:47 PM

To: ASP+

Subject: [aspx] RE: User Controls





Why do you want to do this?  Think of a User control as a black-box. You

should be able to use them on any page, and the user control shouldn't

care what other user controls are or aren't present.  If you try to get

user controls to affect other user control's properties you are

violating this model.



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 5:39 PM

| To: ASP+

| Subject: [aspx] RE: User Controls

|

|

| Thanks Scott.  How about if you have this setup.  I have a main .aspx

| page and on that page I have two user controls.  Can one of the user

| controls get/set properties on the other user control and vice versa

| from within the user control?

|

| Doug

|

| -----Original Message-----

| From: Scott Mitchell [mailto:mitchell@4...]

| Sent: Sunday, March 10, 2002 7:59 PM

| To: ASP+

| Subject: [aspx] RE: User Controls

|

|

| Here's how you could do it, assuming your user control was setup to 

| have a TagPrevix of bleh and a TagName of blah:

|

| <bleh:blah runat="server" id="myUserControl" 

| PropertyName="PropertyValue" />

|

| or you could do it like:

|

| <bleh:blah runat="server" id="myUserControl" />

|

| <script runat="server" language="VB">

|   Sub Page_Load(sender as Object, e as EventArgs)

|     myUserControl.PropertyName = PropertyValue 'where PropertyValue is

| of the right type

|   End Sub

| </script>

|

| hth

|

|     Scott Mitchell

|     mitchell@4...

|

|

| ***********************************************************

|

| Looking to learn ASP.NET?  Look no further than:

|

|    Sams Teach Yourself ASP.NET in 21 Days

|

http://www.amazon.com/exec/obidos/ASIN/0672321688/4guysfromrollaco



***********************************************************



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 2:19 PM

| To: ASP+

| Subject: [aspx] User Controls

|

|

| Hi all,

| I'm using user controls for my site and want to know if its possible 

| to set the values of properties of of the user controls through the 

| main .aspx page.  For example.  I have a label in the user

| control.  I made a

| public property for the user control but can't seem to

| figure out how to

| set the value of the property from the main .aspx page.

| Any help would

| be great.

|

| Doug

|

|

|

| ---

| Change your mail options at http://p2p.wrox.com/manager.asp or to 

| unsubscribe send a blank email to $subst('Email.Unsub').





---

Change your mail options at http://p2p.wrox.com/manager.asp or to

unsubscribe send a blank email to $subst('Email.Unsub').







---

Change your mail options at http://p2p.wrox.com/manager.asp or to

unsubscribe send a blank email to $subst('Email.Unsub').

















Message #7 by "Brzeski, Tom" <Tom.Brzeski@o...> on Mon, 11 Mar 2002 11:20:51 -0500
How this will work with code behind page?



-----Original Message-----

From: Scott Mitchell [mailto:mitchell@4...] 

Sent: Sunday, March 10, 2002 6:59 PM

To: ASP+

Subject: [aspx] RE: User Controls



Here's how you could do it, assuming your user control was setup to

have a TagPrevix of bleh and a TagName of blah:



<bleh:blah runat="server" id="myUserControl"

PropertyName="PropertyValue" />



or you could do it like:



<bleh:blah runat="server" id="myUserControl" />



<script runat="server" language="VB">

  Sub Page_Load(sender as Object, e as EventArgs)

    myUserControl.PropertyName = PropertyValue 'where PropertyValue is

of the right type

  End Sub

</script>



hth



    Scott Mitchell

    mitchell@4...





***********************************************************



Looking to learn ASP.NET?  Look no further than:



   Sams Teach Yourself ASP.NET in 21 Days

   http://www.amazon.com/exec/obidos/ASIN/0672321688/4guysfromrollaco



***********************************************************



| -----Original Message-----

| From: Douglas Rohm [mailto:drohm@a...]

| Sent: Sunday, March 10, 2002 2:19 PM

| To: ASP+

| Subject: [aspx] User Controls

|

|

| Hi all,

| I'm using user controls for my site and want to know if its

| possible to

| set the values of properties of of the user controls

| through the main

| .aspx page.  For example.  I have a label in the user

| control.  I made a

| public property for the user control but can't seem to

| figure out how to

| set the value of the property from the main .aspx page.

| Any help would

| be great.

|

| Doug

|

|

|




| $subst('Email.Unsub').









  Return to Index