SamJolly
asked on
Converting Single Page ASCX to use Codebehind, but server control definition not being generated....????
Dear All,
I have adopted some ASCX single page code which I want to convert to use CBH files for VB.NET code. The process I use to do this is to set the @Control directive as follows:
<%@ Control inherits="" codebehind="header.aspx.vb "%>
I save the file. I then right click on it in solution explorer and select 'View Code'. The CBH is then generated, but without the Server Control definitions. So I have to add them manually :
Protected WithEvents signInOutMsg As System.Web.UI.WebControls. LinkButton
for:
<asp:linkbutton style="FONT: 8pt verdana" id="signInOutMsg" runat="server" />
for example.
Any ideas please.
Thanks,
Sam
I have adopted some ASCX single page code which I want to convert to use CBH files for VB.NET code. The process I use to do this is to set the @Control directive as follows:
<%@ Control inherits="" codebehind="header.aspx.vb
I save the file. I then right click on it in solution explorer and select 'View Code'. The CBH is then generated, but without the Server Control definitions. So I have to add them manually :
Protected WithEvents signInOutMsg As System.Web.UI.WebControls.
for:
<asp:linkbutton style="FONT: 8pt verdana" id="signInOutMsg" runat="server" />
for example.
Any ideas please.
Thanks,
Sam
What happens when you click "View Code" before you do the code behind directive?
ASKER
Have not tried this, but I have tried something else that works. Basically I saved/closed the page with the missing server control definitions then reopened the ascx and double clicked to reveal the CBH and eureka there is there are the definitions - found by accident. I am wondering whether this is one of VS2003's strange behaviours.
Sam
Sam
swapping between design view and html view sometimes works too
ASKER
May be related to quirky VS2003, but if your CBH was inheriting from another class, would you expects the imports to be inherited as well e.g
PARENT CLASS:
Imports System
Imports System.Collections
Imports System.Web.UI
Imports System.Web.Security
Imports System.Configuration
Namespace IBuyAdventure
Public Class PageBase
CHILD CLASS:
Public Class _default
Inherits IBA.IBuyAdventure.PageBase
"System.Web.Security.Forms Authentica tion.SignO ut()" will work not "FormsAuthentication.SignO ut()"
Is this quirky behaviour or do you need to respecify the "Imports" statement for each vb file.
Thanks,
Sam
PARENT CLASS:
Imports System
Imports System.Collections
Imports System.Web.UI
Imports System.Web.Security
Imports System.Configuration
Namespace IBuyAdventure
Public Class PageBase
CHILD CLASS:
Public Class _default
Inherits IBA.IBuyAdventure.PageBase
"System.Web.Security.Forms
Is this quirky behaviour or do you need to respecify the "Imports" statement for each vb file.
Thanks,
Sam
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.