Ask a Question related to ASP.NET General, Design and Development.
-
Carl Prothman [MVP] #1
Re: picking up value in code behind
"Scott Collens" <scottcollens@nospam.hotmail.com> wrote
Scott,> "Carl Prothman [MVP]" <carlpr@spamcop.net> wrote>> > "Scott Collens" <scottcollens@nospam.hotmail.com> wrote> >> > > Hi there, does anyone know if it is possible to set a value in a user
> > > control and pick it up in the code behind.
> > Create a public Property for the User Control. Then in the WebForm's
> > code-behind, call the User Control's Property to get the value.
> Thanks for the response, but I'm a little confused as to how this is picked
> up in the code behind. Can you provide an example? Thanks again....Scott
>
In the User Control, create a public property
public string Username
{
get
{
return TextBox1.Text;
}
set
{
TextBox1.Text = value;
}
}
Then in the code behind of the WebForm (which contains the User Control)
create a protected member variable for the User Control. In this case,
the C# project is called "myProject" and the User Control is called
"UserControlPropertyDemo"
protected myProject.UserControlPropertyDemo UserControlPropertyDemo1;
Then in some event handler, get or set the User Control's public property value
// Set the property value
UserControlPropertyDemo1.Username = "CarlProthman";
// Get the property value
string username = UserControlPropertyDemo1.Username;
--
Thanks,
Carl Prothman
Microsoft ASP.NET MVP
[url]http://www.able-consulting.com[/url]
Carl Prothman [MVP] Guest
-
Picking up where others left off
Hi there, I've recently been employed as a junior web developer updating a website and intranet and i need a lot of help...I mentioned i knew php... -
Ray Picking with director
Ok here is my problem...for picking purposes I need to shoot a ray that goes from my mouse pointer (using spriteSpaceToWorldSpace) on to screen... -
help on picking up key & values
Joseph, Let me try and explain. i have a perl script place_order which takes arguments as below: 1. ./place_order -t... -
picking lingo
HI, I'm finding it really hard to get to grips with picking lingo...been through many examples but can't seem to get it working. Could somebody... -
'while' not picking up on first DB record
Hello, Can anyone from the lists please tell me why this bit of code is not picking up on the first record in the database? If the 'id' I'm...



Reply With Quote

