Groups | Blog | Home
all groups > dotnet general > october 2004 >

dotnet general : User Controls


Tome73
10/23/2004 3:59:03 PM
When trying to access properties of a User Control while using Code Behind I
am running into a brick wall. I can create the User Control using a Code
Behind page with no problem, but after embedding it in a Web page I can’t
access its properties. Take for example the Microsoft’s QuickStart example
Pagelet4: I can access the properties on my aspx page if I included the code
directly on the page using <script> code render blocks </script> like this:

<script language="C#" runat="server">
void Page_Load(Object sender, EventArgs E) {

if (Page.IsPostBack) {
MyLabel.Text += "The UserId is " + MyLogin.UserId + "<br>";
MyLabel.Text += "The Password is " + MyLogin.Password + "<br>";
}
}
</script>

But when I try and access MyLogin.UserId from a Codebehind page of the web
form I get an error saying that the definition can’t be found. Can anyone
help me with this?
Thanks
Allan
10/24/2004 1:51:04 PM
check the "web form designer generated code" section of the page if the user
control has been registered. there should be a line which reads something
like this :

protected with events myusercontrol as usercontrolname

if its not there. put it.

[quoted text, click to view]
AddThis Social Bookmark Button