Forum Moderators: open

Message Too Old, No Replies

Passing values from a user control (ascx) to the page (aspx)

Anyone know a good tutorial?

         

Jimmy Turnip

3:12 pm on Nov 22, 2004 (gmt 0)

10+ Year Member



Got a user control with text boxes and I need to validate the text boxes in the control and then pass the values to the page when a submit button in the user control is pressed. Does anyone know the best way to do this, or know any good tutorials, cuz I'm really struggling?

Thanks

tomasz

6:43 pm on Nov 22, 2004 (gmt 0)

10+ Year Member



First u need to have Public variable at your user form

Public TextBoxValue as string

then create a code for your user form, then on you aspx drop placeholder which can be loaded and set from your aspx page

Dim ctl As Control = LoadControl("example.ascx")
CType(ctl, example ).TextBoxValue = SomeTextHere
PlaceHolder1.Controls.Add(ctl)

see user controls at [odetocode.com...]

Jimmy Turnip

9:08 am on Nov 23, 2004 (gmt 0)

10+ Year Member



Thanks man, but I found the problem. Visual studio doesn't add a:

Protected WithEvents MyUserControl1 As MyUserControl

In the header as it does with the other built in web components you drop into the designer. Once I added that I could then refer to its properties and methods.