passing variables from webform to usercontrol code

  • Thread starter Thread starter DC Gringo
  • Start date Start date
D

DC Gringo

I have a two panel controls, one that shows if PageID = 10000 and the other
when PageID = 10001. Problem is that these variables are set in the
usercontrol.ascx.vb rather than the calling webform index.aspx.vb. How can
I declare and set this variable from the webform and have the user control
recognize it?

---Here are my Panels:---

<asp:Panel id="Panel1" runat="server">
...html1
</asp:Panel>

<asp:Panel id="Panel2" runat="server">
...html2
</asp:Panel>


---Here is my Sub Page_Load in----


Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim PageID As Integer
PageID = 10000

If PageID = 10000 Then
Panel1.Visible = True
Panel2.Visible = False
ElseIf PageID = 10001 Then
Panel1.Visible = False
Panel2.Visible = True
End If


End Sub
 
Declare two public property in your usercontrol and then set this property
from your webform codebehind file,
 
Back
Top