user control question

Results 1 to 3 of 3

Thread: user control question

  1. #1
    Join Date
    Dec 1969

    Default user control question

    Im having trouble with a user control, but more-so I&#039;m having an issue with the user control and codebehind. <BR><BR>Here is the problem. I have a very very simple user control. Its taking a value from a textbox and displaying it in a label after a button has been pushed. I am having a problem in VS.Net. I have the code embedded in an aspx page, but want to move it to a codebehind page. <BR><BR><BR><BR>Private Sub Page_Load(sender As Object,e as EventArgs)<BR><BR> lblMessage.Text = WebUserControl11.BackColor<BR><BR>End Sub<BR><BR><BR><BR><BR>It excecutes fine when it is embedded, but if it is in a code behind page it bombs on the usercontrol.backcolor <BR><BR>Could someone please give some insight on why this is happening, or what the exact difference is between embedding the code in script tags versus a code behind page? <BR>

  2. #2
    Join Date
    Dec 1969

    Default you need the get the text attribute of your textbo

    Private Sub Page_Load(sender As Object,e as EventArgs)<BR><BR>lblMessage.Text = theNameOfYourTextBox.Text<BR><BR>End Sub

  3. #3
    Join Date
    Dec 1969

    Default RE: user control question

    You need to declare all of your webControls in the code behind out side of any function like<BR><BR>protected lblMessage as label<BR>protected tbxColor as textBox<BR><BR>before you can reference them

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts