Search code examples
vb.netmaster-pages

Cast web control to html control with in master page


I'm trying to clean up some existing VB code. Issue is I've created a master page and trying to using a already created user control with in the content holder of the master page. I've attached a image of the error

enter image description here.
I'm not exactly sure how to cast this with in VB.

Here is the code that is causing the error.

            --->Dim myPage As HtmlControls.HtmlForm = Me.Parent
        Dim myParent As Page = myPage.Parent
        If myParent.ToString.Contains("private_accountinfo") AndAlso prevPage.Contains("Default_Login") Then
            pnlMenu.Visible = False
        ElseIf myParent.ToString.Contains("default_support") And Session("Utente") = "" Then
            pnlMenu.Visible = False

Thanks


Solution

  • The solution is in your error message. You have a ContentPlaceHolder, but you're dimming it as an HtmlForm. Don't do that. Use:

    Dim myPage As HtmlControls.ContentPlaceHolder = Me.Parent