B
Brian Lowe
I have several aspx pages that include a couple of asplaceholder controls,
an example is myPage.aspx.
The page inherits from a custom class 'myClass' which inherits
System.Web.UI.Page which lets me ad my own properties and methods to a bunch
of pages in my app.
I want code in myClass to set the contents of the placeholders in myPage.
If I insert the mark-up <asplaceholder id="myPlaceholder" runat="server"
/> in myPage.aspx and I declare the placeholders in myClass as Protected
WithEvents myPlaceholder As System.Web.UI.WebControls.PlaceHolder
my application runs fine but...
As soon as I edit anything in Visual Studio it sees the placeholder markup
in the .aspx and generates a corresponding
Protected WithEvents myPlaceholder As System.Web.UI.WebControls.PlaceHolder
in myPage.aspx.vb
This is bad! Now the application won't run because myPlaceholder is declared
twice - once in the page code behind and once in the myClass which it
inherits.
If I delete the declaration from the underlying class the code in that class
can't access the placeholder in the page. So I must delete the
auto-generated lines form the .aspx.vb code to get it to run.
Now, when the offending lines are in place the systax checker highlights the
declaration (in myPage.aspx.vb) as conflicting (with that in myClass.vb) and
says I should be using 'shadows' - but where?
Do I declare the placeholder in myClass as shadowing the one in the page, or
do I declare the one in the page as shadowing the one in myClass? What is
the correct syntax, and will it stop Visual Studio from autogenerating
invalid code?
Brian Lowe
---------@
an example is myPage.aspx.
The page inherits from a custom class 'myClass' which inherits
System.Web.UI.Page which lets me ad my own properties and methods to a bunch
of pages in my app.
I want code in myClass to set the contents of the placeholders in myPage.
If I insert the mark-up <asplaceholder id="myPlaceholder" runat="server"
/> in myPage.aspx and I declare the placeholders in myClass as Protected
WithEvents myPlaceholder As System.Web.UI.WebControls.PlaceHolder
my application runs fine but...
As soon as I edit anything in Visual Studio it sees the placeholder markup
in the .aspx and generates a corresponding
Protected WithEvents myPlaceholder As System.Web.UI.WebControls.PlaceHolder
in myPage.aspx.vb
This is bad! Now the application won't run because myPlaceholder is declared
twice - once in the page code behind and once in the myClass which it
inherits.
If I delete the declaration from the underlying class the code in that class
can't access the placeholder in the page. So I must delete the
auto-generated lines form the .aspx.vb code to get it to run.
Now, when the offending lines are in place the systax checker highlights the
declaration (in myPage.aspx.vb) as conflicting (with that in myClass.vb) and
says I should be using 'shadows' - but where?
Do I declare the placeholder in myClass as shadowing the one in the page, or
do I declare the one in the page as shadowing the one in myClass? What is
the correct syntax, and will it stop Visual Studio from autogenerating
invalid code?
Brian Lowe
---------@