passing variables from webform to usercontrol code

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
 
S

Saravana [MVP]

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

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