User Controls

G

Guest

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
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top