Link to home
Start Free TrialLog in
Avatar of SamJolly
SamJollyFlag for United Kingdom of Great Britain and Northern Ireland

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
Avatar of NowaY
NowaY

What happens when you click "View Code" before you do the code behind directive?
Avatar of SamJolly

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
swapping between design view and html view sometimes works too
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.FormsAuthentication.SignOut()" will work not "FormsAuthentication.SignOut()"

Is this quirky behaviour or do you need to respecify the "Imports" statement for each vb file.

Thanks,

Sam
ASKER CERTIFIED SOLUTION
Avatar of PeterFearn
PeterFearn

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial