Re: .Net Newbie web user control question
From: Craig (Craig_at_discussions.microsoft.com)
Date: 10/05/04
- Next message: Alex Homer: "Re: Datagrid Expand/Collapse"
- Previous message: Michael Persaud: "Dataset items to variables !!! URGENT!!!"
- In reply to: Robert Koritnik: "Re: .Net Newbie web user control question"
- Next in thread: Robert Koritnik: "Re: .Net Newbie web user control question"
- Reply: Robert Koritnik: "Re: .Net Newbie web user control question"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 5 Oct 2004 14:03:04 -0700
I tried dragging the user control to the web form in design view, but it
didn't create a declaration for the user control. This is what shows up in
the auto generated in the code behind:
Public Class _default
Inherits System.Web.UI.Page
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub
InitializeComponent()
End Sub
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
"Robert Koritnik" wrote:
> Probably you didn't put your control as a protected (at least) declaration
> in the page's codebehind. When you have server controls in the ASPX and not
> declared in the codebehind, those controls don't get by any chance
> automaticly created in the codebehind.
>
> If you would use Design view instead of the HTML view of your page, the
> protected declaration would be automaticly created for you in the
> codebehind.
>
> --
> RobertK
> { Clever? No just smart. }
>
> "Craig" <Craig@discussions.microsoft.com> wrote in message
> news:46A877D9-82FA-4253-875A-AF2F7589EA2D@microsoft.com...
> > I'm having a problem calling a public method for a web user control. When
> I
> > reference the UC's id (MyTester) from within default.aspx.vb, I get a
> message
> > that the variable has not been declared. I'm posting the code below, can
> > anyone help out with this.
> >
> > the statement that throws the error is:
> > [default.aspx.vb]
> > MyTester.SetAppInfo(1001)
> >
> >
> > [default.aspx]
> > <%@ Register tagprefix="test" tagname="Message"
> > src="UserControls/tester.ascx" %>
> > <%@ Page Language="vb" AutoEventWireup="false"
> Codebehind="default.aspx.vb"
> > Inherits="MasterSite._default"%>
> > [snip]
> > <form id="Form1" method="post" runat="server">
> > <test:message id="MyTester" runat="server" />
> > </form>
> > [snip]
> >
> > [default.aspx.vb]
> > Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > MyTester.SetAppInfo(1001)
> > end Sub
> >
> >
> > [tester.ascx]
> > <%@ Control Language="vb" AutoEventWireup="false"
> > Codebehind="tester.ascx.vb" Inherits="MasterSite.tester"
> > TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
> > <asp:Label id="lblTester" runat="server"></asp:Label>
> >
> > [tester.ascx.vb]
> > Public Class tester
> > Inherits System.Web.UI.UserControl
> > Private _AppId As Integer
> > [snip]
> > Public Sub SetAppInfo(ByVal AppId As Integer)
> > 'do some biz logic here
> > _AppId = AppId
> > End Sub
> >
> > End Class
> >
>
>
>
- Next message: Alex Homer: "Re: Datagrid Expand/Collapse"
- Previous message: Michael Persaud: "Dataset items to variables !!! URGENT!!!"
- In reply to: Robert Koritnik: "Re: .Net Newbie web user control question"
- Next in thread: Robert Koritnik: "Re: .Net Newbie web user control question"
- Reply: Robert Koritnik: "Re: .Net Newbie web user control question"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|