Ask a Question related to ASP.NET General, Design and Development.
-
Steve C. Orr, MCSD #1
Re: user control - passing values
You could declare your the controls inside your user control as public
instead of the default of protected.
Then you can access them directly from your web form like this:
MyControl.MyDropdown.ToString...
But rather than unprotecting your controls you might want to take a more
object oriented approach and make special methods on your user control to
expose specific control values to the page.
For example, if you have a public method in your user control like this:
Public Function MyDropDownListValue() as String
Return MyDropDownList.ToString
End Function
Then you can call the method from your main page like this:
MyControl.MyDropDownListValue
--
I hope this helps,
Steve C. Orr, MCSD
[url]http://Steve.Orr.net[/url]
"Sabre" <maximNOSPAM@wave.co.nz> wrote in message
news:OC5Srv$RDHA.3144@tk2msftngp13.phx.gbl...is> Hello All
>
> I've got a form with one user control embedded. Both contain textboxes,
> dropdownlists and checkboxes. Short of using sessions (haven't tried
> viewstate) what means can be used to pass values between? So if checkbox1Similarly> checked on the form, I'd like the user control to recognise this.in> if a textbox on my user control contains text, I'd like to use this text> my form.
>
> TIA
> Graeme
>
>
Steve C. Orr, MCSD Guest
-
How to access values of constituent controls in a User Control
Hi All, I am building what I thought was a very simple user control in ASP.NET. The control is just a standard asp.net calendar control and a... -
Passing values to a custom control
I am building a custom composite control which reads in information from an XML file. I want to be able to point my control at different XML files... -
Passing values from a web user control using a class - ???
Hi. I have a web form that contains a custom user control. This control is a questionnaire with 20 questions that contains multiple radio buttons,... -
Passing values in User control
You can create public properties of any data type in the user control (which is a class, after all), and then set them from the page which uses the... -
passing values to custom user control from dropdownlist
i have custom user control and i'm trying to pass values to custom user control......I need help it seems to me i cannot pass the value to user... -
Sabre #2
Re: user control - passing values
Thanks Steve. You certainly got all the answers! Regards, Graeme
"Steve C. Orr, MCSD" <Steve@Orr.net> wrote in message
news:uIErZXASDHA.2252@TK2MSFTNGP12.phx.gbl...checkbox1> You could declare your the controls inside your user control as public
> instead of the default of protected.
> Then you can access them directly from your web form like this:
> MyControl.MyDropdown.ToString...
>
> But rather than unprotecting your controls you might want to take a more
> object oriented approach and make special methods on your user control to
> expose specific control values to the page.
>
> For example, if you have a public method in your user control like this:
> Public Function MyDropDownListValue() as String
> Return MyDropDownList.ToString
> End Function
>
> Then you can call the method from your main page like this:
> MyControl.MyDropDownListValue
>
> --
> I hope this helps,
> Steve C. Orr, MCSD
> [url]http://Steve.Orr.net[/url]
>
>
>
> "Sabre" <maximNOSPAM@wave.co.nz> wrote in message
> news:OC5Srv$RDHA.3144@tk2msftngp13.phx.gbl...> > Hello All
> >
> > I've got a form with one user control embedded. Both contain textboxes,
> > dropdownlists and checkboxes. Short of using sessions (haven't tried
> > viewstate) what means can be used to pass values between? So if> is> Similarly> > checked on the form, I'd like the user control to recognise this.> in> > if a textbox on my user control contains text, I'd like to use this text>> > my form.
> >
> > TIA
> > Graeme
> >
> >
>
Sabre Guest
-
Sabre #3
Re: user control - passing values
OK Steve. I've taken the easy route and declared controls as Public Shared
WithEvents within the user control and then referenced them from aspx form
like so:
WebUserControl1.DropDownList4.SelectedIndex =
WebUserControl1.DropDownList4.Items.IndexOf(WebUse rControl1.DropDownList4.It
ems.FindByText(Session("ID")))
That eliminated the errors ... now to overcome the "Event handler must be
shared because its WithEvents var is shared" in the ascx page it appears I
need to change the associated event to Public Shared like so:
Public Shared Sub DropDownList4_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList3.SelectedIndexChanged
This seems fine too, but now I get the error "cannot refer to an instance
member of class within a shared method or shared member initializer without
an explicit instance of class" with all subs; sessions etc within the
procedure eg:
Button6_Click(sender, e) within the proc now errs.
I've tried a few things, but so far, to no avail. Can you or anyone else
help further?
Thanks again
Graeme
"Steve C. Orr, MCSD" <Steve@Orr.net> wrote in message
news:uIErZXASDHA.2252@TK2MSFTNGP12.phx.gbl...checkbox1> You could declare your the controls inside your user control as public
> instead of the default of protected.
> Then you can access them directly from your web form like this:
> MyControl.MyDropdown.ToString...
>
> But rather than unprotecting your controls you might want to take a more
> object oriented approach and make special methods on your user control to
> expose specific control values to the page.
>
> For example, if you have a public method in your user control like this:
> Public Function MyDropDownListValue() as String
> Return MyDropDownList.ToString
> End Function
>
> Then you can call the method from your main page like this:
> MyControl.MyDropDownListValue
>
> --
> I hope this helps,
> Steve C. Orr, MCSD
> [url]http://Steve.Orr.net[/url]
>
>
>
> "Sabre" <maximNOSPAM@wave.co.nz> wrote in message
> news:OC5Srv$RDHA.3144@tk2msftngp13.phx.gbl...> > Hello All
> >
> > I've got a form with one user control embedded. Both contain textboxes,
> > dropdownlists and checkboxes. Short of using sessions (haven't tried
> > viewstate) what means can be used to pass values between? So if> is> Similarly> > checked on the form, I'd like the user control to recognise this.> in> > if a textbox on my user control contains text, I'd like to use this text>> > my form.
> >
> > TIA
> > Graeme
> >
> >
>
Sabre Guest



Reply With Quote

