Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Code-Behind Pain in the Behind!

Thread Tools

Code-Behind Pain in the Behind!

Posts: n/a
Okay, answer to my own question...sort of. My original search was
apparently in the wrong "department" of the msdn site. There is info on
late binding for .NET, so I gave it a try.

First, it said something about "can't do late binding with option
strict." So, I turned option strict off. Then it said something about
"can't create ActiveX object 'blah blah.'"

Back to the drawing board.


Reply With Quote
Posts: n/a
if your not using visual studio then you don't need all that crappy code

put your header code into an ascx file
then in your aspx file use load control and a place holder

"Daniel Manes" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)
> Okay, here are the facts ma'am (or mister):
> 1. I have a user control called "Header" and a main page called
> "ReportMatch".
> 2. I've written "code-behinds" for both the user control and the main
> page.
> 3. This means four files: Ladder.ascx, Ladder.ascx.vb,
> ReportMatch.aspx, and ReportMatch.aspx.vb.
> 4. None of this stuff is precompiled, and I would prefer not to have to
> mess with precompiling and dll's and all that jazz (and I don't have
> VS.NET).
> 5. I have Option Strict turned on.
> 6. I can get the Header to show up in ReportMatch (yay!), but if I try
> to declare a variable in the ReportMatch code-behind as type Header, I
> get the error "BC30002: Type 'Header' is not defined" (boo!).
> So, my question:
> Is there any way to get this error to stop occurring? Please tell me
> there is. I'm going crazy here!
> Here are some code snippets (all in VB.NET):
> ********** from Ladder.ascx **********
> <%@ Control Language="VB" Explicit="True" Strict="True" Debug="True"
> Src="Ladder.ascx.vb" %>
> <table> ... some links ... </table>
> ********** from Ladder.ascx.vb **********
> Option Explicit
> Option Strict
> Imports System, System.Configuration, System.Data, System.Data.Odbc,
> System.Web.UI, System.Web.UI.WebControls
> Public Class Header
> Inherits UserControl
> Public LogInLink As HyperLink
> 'A few more declarations like this -- snipped
> Sub InitConnectObj
> Dim ConnectStr As String
> ConnectStr = ConfigurationSettings.AppSettings("ConnectStr")
> ConnectObjG.ConnectionString = ConnectStr
> End Sub
> 'Another method -- snipped
> End Class
> ********** from ReportMatch.ascx **********
> <%@ Page Language="VB" Explicit="True" Strict="True" Debug="True"
> Src="ReportMatch.aspx.vb" %>
> <%@ Register TagPrefix="Ladder" TagName="Header" Src="Ladder.ascx" %>
> <html><head> ... </head>
> <body><form runat="server">
> <Ladder:Header ID="HeaderCtrl" runat="server" />
> <table> ... some stuff ... </table>
> ... some custom validator tags ...
> </form></body></html>
> ********** from ReportMatch.ascx.vb **********
> Option Explicit
> Option Strict
> Imports Microsoft.VisualBasic, System, System.Configuration,
> System.Collections, System.Data, System.Data.Odbc, System.Math,
> System.Web.UI, System.Web.UI.WebControls
> Public Class ReportMatch
> Inherits Page
> Public HeaderCtrl As Header = CType(LoadControl("Ladder.ascx.vb"),
> Header) 'This generates the error "BC30002: Type 'Header' is not
> defined"!!!
> Public DateCtrl As Calendar
> 'A few more declarations like this -- snipped
> Sub Page_Load(Sender As Object, E As EventArgs)
> HeaderCtrl.InitConnectObj() 'If I try to declare HeaderCtrl As Type
> Control or UserControl, this doesn't work because InitConnectObj is not
> a method of either of those classes.
> 'Some other stuff -- snipped
> End Sub
> 'Several methods and validation handlers -- snipped
> End Class
> I've scoured this newsgroup and Google and tried seemingly everything
> (except precompiling into dll's, which I hope I don't have to do), and
> I just can't get this thing working.
> Thanks in advance! (or TIA! if you prefer your thank you's in acronym
> form)
> -Dan

Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chronic Back Pain Michael MCSD 0 04-02-2006 02:43 AM
Chronic Back Pain Michael MCSE 0 04-02-2006 02:43 AM
Modelsim error: Cannot read output pain Olaf Petzold VHDL 12 12-23-2005 09:15 PM
Sorry to be such a pain Brent White ASP .Net 5 10-25-2005 09:15 PM
DropDownList Pain =?Utf-8?B?S1JN?= ASP .Net 2 05-25-2005 04:28 PM