Click to See Complete Forum and Search --> : How are you doing things?
jesus4u
May 7th, 2003, 03:21 PM
In an aspx page if you want to display a name in a certain area on the page are you loading it like the old asp way in a variable or what?
Thanks
Cander
May 7th, 2003, 03:25 PM
Stick a label web form control where you want it, then set its .Text property ot whatever text you want.
jesus4u
May 7th, 2003, 03:25 PM
Originally posted by Cander
Stick a label web form control where you want it, then set its .Text property ot whatever text you want.
yes that is one way, thanks
Cander
May 7th, 2003, 03:27 PM
Best way too. :D
jesus4u
May 7th, 2003, 03:28 PM
Originally posted by Cander
Best way too. :D
well I don't know about that. Can a label be controlled by a style sheet?
Cander
May 7th, 2003, 03:29 PM
yes. Use the .cssclass property!
Or just .style property to directly specify the style string.
hellswraith
May 7th, 2003, 03:30 PM
Yep
Edneeis
May 7th, 2003, 03:34 PM
I thought I read somewhere that aspx is a bit beefy on the resources and so it was recommanded to write as much as is convenient (sp?) in old scholl asp. What do you think, Fact or Fiction?
My pages usually end up being a half and half mix, depending on how lazy I get. Although I at least structure it so it makes sense.
Cander
May 7th, 2003, 03:36 PM
I use 0% old stuff. But I also dont use 100% web form controls. use plain HTML whenever possible.
hellswraith
May 7th, 2003, 06:17 PM
I think mixing old style and the new code behind is actually hurting your performance. I don't think that ASP.Net is actually compiling your code that it embedded in the page itself.
With all your code in code behind pages, they get compiled into a dll, and also get JIT just once, creating more speed. That is one big benefit to running code behind pages.
hellswraith
May 7th, 2003, 06:19 PM
Originally posted by Cander
I use 0% old stuff. But I also dont use 100% web form controls. use plain HTML whenever possible.
Exactly, you got to strike a balance. If you don't need to create a table in code, don't. It won't be any faster. I only use the web form controls when I will absolutely have to change values or get the values from them when I am processing the page.
hellswraith
May 7th, 2003, 06:23 PM
One more thing, use web controls whenever you can. I use one for the header, one for the footer, one for navigation....etc. Anywhere I need the exact same thing on the pages. They are a huge timesaver, plus, you only fix something at one place instead of every page.
Cander
May 7th, 2003, 07:19 PM
definatly.
.ascx controls are excellent.
Sure you used to have include files, .ascx offers so muhc more flexability.
Edneeis
May 7th, 2003, 09:05 PM
Well I don't know that it would really hurt performance, most of the things I still use are simple IF statements and what not to show or not show certain things based on say login. Also I often call the compiled aspx code from within the old style <%%> scripts if I need to do any dirty work. I still use includes what is the .net replacement?
I think I'll look into asp.net a bit more.
hellswraith
May 7th, 2003, 09:16 PM
I guess I shouldn't have said 'hurt' performance, but I should have said you can get a performance boost by using compiled code instead of having to rely on your code being interpreted.
It probably isn't much really, but if you have any complex logic that needs to be performed quickly, then code behind would be ideal.
jesus4u
May 8th, 2003, 07:07 AM
All of your comments have REALLY helped.
One more thing I noticed is that .NET is STILL not that friendly for simply developing nice formatted webpages. And it appears I still need to take it into FrontPage then import back in.
jesus4u
May 8th, 2003, 07:13 AM
Originally posted by Cander
definatly.
.ascx controls are excellent.
Sure you used to have include files, .ascx offers so muhc more flexability.
Really? Can you please explain a little more?
Cander
May 8th, 2003, 08:21 AM
Actually, ASP.NET is much more friendly than ever before. At least if you are using Visual Studio .NET. it feels just like I am creating a Windows application. Drag, drop, double click, code!:D Coding web form controls is just like using VB controls like you are used to.
(I am starting to sound like an ad for .NET :p)
About .ascx controls. Basically they are templates of reuseable HTML and ASP.NET. Sort of like include files. But now you can give them properties and the abilities of coding a regualr asp.net page. Then when you want to use it in your pages, it is a simple matter of adding it where you want it like you would other web form controls.
In VS.NET, start yourself a ASP.NET project. Add an .ASCX User Control. Stick some simple HTML code in it. The drag the file from your Solution Explorer to your Webform.aspx page. If you look at the HTML code for the aspx page, you will see a line of code near the top of the page which sets up the control for use, then you will see in your main body of code, the code that looks like other web form controls
ie
<mycontrol:newcontrol runat="server"/>
Also as I said prev iously, you can add properties into the .ascx code behind, and call them with attributes
ie
<mycontrol:newcontrol myproperty="Hey" runat="server"/>
The only downside of the .ascx is that it doesnt render in the VS.NET designer. All you see is a box that says UserControl. Hopefully they will fix that omeday, but it s not too big a deal
jesus4u
May 8th, 2003, 08:26 AM
Originally posted by Cander
Actually, ASP.NET is much more friendly than ever before. At least if you are using Visual Studio .NET. it feels just like I am creating a Windows application. Drag, drop, double click, code!:D Coding web form controls is just like using VB controls like you are used to.
(I am starting to sound like an ad for .NET :p)
About .ascx controls. Basically they are templates of reuseable HTML and ASP.NET. Sort of like include files. But now you can give them properties and the abilities of coding a regualr asp.net page. Then when you want to use it in your pages, it is a simple matter of adding it where you want it like you would other web form controls.
In VS.NET, start yourself a ASP.NET project. Add an .ASCX User Control. Stick some simple HTML code in it. The drag the file from your Solution Explorer to your Webform.aspx page. If you look at the HTML code for the aspx page, you will see a line of code near the top of the page which sets up the control for use, then you will see in your main body of code, the code that looks like other web form controls
ie
<mycontrol:newcontrol runat="server"/>
Also as I said prev iously, you can add properties into the .ascx code behind, and call them with attributes
ie
<mycontrol:newcontrol myproperty="Hey" runat="server"/>
The only downside of the .ascx is that it doesnt render in the VS.NET designer. All you see is a box that says UserControl. Hopefully they will fix that omeday, but it s not too big a deal
Very insightful! Thanks :cool:
hellswraith
May 8th, 2003, 10:01 AM
Just to add to what Cander was saying...
ASCX controls also can have their own code behind files. So if you need to do some processing based on the page the control is on, or display something based on some other value, you can easily do this. Remember when developing the control, that it will be embedded in a page object, which means you will have access to all the pages functionalities for the most part. Like if you want to get the querystring in the control, you can go ahead and get it. If you want to find the page that the control is on, you can just use this.PageName.ToString() to figure out which page it is on (Extremely helpful when you are writing a navigation control to be used on all your pages).
Lots of flexibility for them, plus less code to write.
Eras3r
May 8th, 2003, 04:18 PM
Excellent thread, wow!
Edneeis
May 13th, 2003, 12:39 AM
ASCX controls do kick butt. I've seen the errors of my ways and been converted. I have a couple questions though, which I'll start a new thread for.
PT Exorcist
May 18th, 2003, 10:15 AM
i cannot seem to can do that thing of ascx..i've created a file .ascx, i've put some code on it and then i've dragged it in solution explorer over other aspx web page and it says that cant move it because its in the same folder..i dont get what i am doing wrong..
hellswraith? cander? anyone?
PT Exorcist
May 18th, 2003, 10:21 AM
ah! i had to drag it over the designer! now it seems to work :p
jesus4u
May 19th, 2003, 08:53 AM
Originally posted by Cander
Actually, ASP.NET is much more friendly than ever before. At least if you are using Visual Studio .NET. it feels just like I am creating a Windows application. Drag, drop, double click, code!:D Coding web form controls is just like using VB controls like you are used to.
(I am starting to sound like an ad for .NET :p)
About .ascx controls. Basically they are templates of reuseable HTML and ASP.NET. Sort of like include files. But now you can give them properties and the abilities of coding a regualr asp.net page. Then when you want to use it in your pages, it is a simple matter of adding it where you want it like you would other web form controls.
In VS.NET, start yourself a ASP.NET project. Add an .ASCX User Control. Stick some simple HTML code in it. The drag the file from your Solution Explorer to your Webform.aspx page. If you look at the HTML code for the aspx page, you will see a line of code near the top of the page which sets up the control for use, then you will see in your main body of code, the code that looks like other web form controls
ie
<mycontrol:newcontrol runat="server"/>
Also as I said prev iously, you can add properties into the .ascx code behind, and call them with attributes
ie
<mycontrol:newcontrol myproperty="Hey" runat="server"/>
The only downside of the .ascx is that it doesnt render in the VS.NET designer. All you see is a box that says UserControl. Hopefully they will fix that omeday, but it s not too big a deal
Maybe you can help?
I get an object not instantiated error when trying to set the PictureLocation property of my WEb USer Control named MainAnnouncement in the code behind page of the PARENT aspx page.
How to fix?
'Code Behind of the PARENT .ASPX page
Imports DotIntranet.MainAnnouncement 'THIS IS THE ASCX CLASS
Public Class accounting
Inherits System.Web.UI.Page
Protected WithEvents lblDate As System.Web.UI.WebControls.Label
Protected WithEvents lblDept As System.Web.UI.WebControls.Label
Dim MainAnn As MainAnnouncement
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
lblDate.Text = Today.ToLongDateString
'Here we get the data necessary to fill the User Coctrol via properties.
MainAnn.PictureLocation = "../images/Bible.jpg"
End Sub
End Class
'WebUserControl Page
Public MustInherit Class MainAnnouncement
Inherits System.Web.UI.UserControl
Private strPictureLocation As String
Public Property PictureLocation() As String
Get
Return strPictureLocation
End Get
Set(ByVal Value As String)
strPictureLocation = Value
End Set
End Property
End Class
Cander
May 19th, 2003, 08:57 AM
did you drag and drop the .ascx to the main aspx page and name it MainAnn ?
jesus4u
May 19th, 2003, 08:58 AM
Originally posted by Cander
did you drag and drop the .ascx to the main aspx page and name it MainAnn ?
Well, I dragged and dropped it and it named it MainAnnouncement1 but I can't seem to reference that name in the codebehind.
???????????????????????????? I confused...
jesus4u
May 19th, 2003, 08:59 AM
And when I try this..
Dim MainAnn As MainAnnouncement1...
IT says that it is NOT defined.
Cander
May 19th, 2003, 09:02 AM
the
Dim statment has to be
Dim thecontrolname As theClassname
so it should be
Dim MainAnnouncement1 As MainAnnouncement
jesus4u
May 19th, 2003, 09:04 AM
Thanks tried that but ....
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 26: lblDate.Text = Today.ToLongDateString
Line 27: 'Here we get the data necessary to fill the User Coctrol via properties.
Line 28: MainAnnouncement1.PictureLocation = "../images/Bible.jpg"
Line 29:
Line 30: End Sub
jesus4u
May 19th, 2003, 09:07 AM
Wait! Dummy me I think I am doing this all wrong. What I am trying to do is set the ImageLocation of an existing Image control on the ASCX file. Know what I mean? So how can I reference the Image Control from the Parent page?
Cander
May 19th, 2003, 09:07 AM
hmm..Maybe take out that MustInherit from the
UserControl class since you dont specifically inherit it..
???
Cander
May 19th, 2003, 09:11 AM
Originally posted by jesus4u
Wait! Dummy me I think I am doing this all wrong. What I am trying to do is set the ImageLocation of an existing Image control on the ASCX file. Know what I mean? So how can I reference the Image Control from the Parent page?
Well you access the image control from the code bwhind by doing a declaration exactly as I mentioned above
Dim thecontrolname_as_it_is_named_on_the_page As Class/object_name
jesus4u
May 19th, 2003, 09:11 AM
I made your change...nothing and I exposed the Image Control like so..
Public Class MainAnnouncement
Public WithEvents imgMain As System.Web.UI.WebControls.Image
but again when trying to set the property in code it gives me the same error. What is up?
Cander
May 19th, 2003, 09:14 AM
User Controls are really meant to access their own control within it. So put that image control into the User Control
Cander
May 19th, 2003, 09:14 AM
User Controls are really meant to access their own control within it. So put that image control into the User Control
jesus4u
May 19th, 2003, 09:20 AM
Originally posted by Cander
User Controls are really meant to access their own control within it. So put that image control into the User Control
It IS in the control already.
Cander
May 19th, 2003, 09:22 AM
Ok. I think you need you ned to zip up the project and post it. I dont think I am understanding what you are saying. Post it if you can so I can take a look.
jesus4u
May 19th, 2003, 09:30 AM
The project is very large but here is the code. I will clearly comment.
'ASCX HTML
<%@ Control Language="vb" AutoEventWireup="false" Codebehind="MainAnnouncement.ascx.vb" Inherits="DotIntranet.MainAnnouncement" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>
<DIV style="WIDTH: 421px; POSITION: relative; HEIGHT: 281px" ms_positioning="GridLayout">
<asp:Image id="imgMain" style="Z-INDEX: 101; LEFT: 1px; POSITION: absolute; TOP: 1px" runat="server" Width="67px" Height="73px" ImageUrl='<%# DataBinder.Eval(DsNewMinAnn1, "Tables[GetDeptMainAnnouncement].DefaultView.[0].PictureLocation") %>'>
</asp:Image>
<asp:Label id="lblTitle" style="Z-INDEX: 102; LEFT: 81px; POSITION: absolute; TOP: 3px" runat="server" Width="298px" CssClass="MinistryAnnouncements_Title" Text='<%# DataBinder.Eval(DsNewMinAnn1, "Tables[GetDeptMainAnnouncement].DefaultView.[0].AnnouncementTitle") %>'>
</asp:Label>
<asp:Label id="lblLastName" style="Z-INDEX: 103; LEFT: 149px; POSITION: absolute; TOP: 61px" runat="server" Width="136px" Height="9px" CssClass="MinistryAnnouncements_Name"></asp:Label>
<asp:Label id="lblName" style="Z-INDEX: 104; LEFT: 115px; POSITION: absolute; TOP: 61px" runat="server" Width="85px" Height="8px" CssClass="MinistryAnnouncements_Name" Text='<%# DataBinder.Eval(DsNewMinAnn1, "Tables[GetDeptMainAnnouncement].DefaultView.[0].UserFirstName") %>'>
</asp:Label>
<asp:Label id="lblText" style="Z-INDEX: 105; LEFT: 117px; POSITION: absolute; TOP: 87px" runat="server" Width="301px" Height="154px" CssClass="MinistryAnnouncements_Text"></asp:Label><IMG style="Z-INDEX: 106; LEFT: 126px; WIDTH: 295px; POSITION: absolute; TOP: 272px; HEIGHT: 1px" height="1" src="images/defaul3.gif" width="295"></DIV>
'ASCX Code Behind
Public Class MainAnnouncement
Inherits System.Web.UI.UserControl
Protected WithEvents lblTitle As System.Web.UI.WebControls.Label
Protected WithEvents lblName As System.Web.UI.WebControls.Label
Protected WithEvents lblLastName As System.Web.UI.WebControls.Label
Protected WithEvents lblText As System.Web.UI.WebControls.Label
Protected WithEvents SqlConnection1 As System.Data.SqlClient.SqlConnection
Protected WithEvents daMainAnn As System.Data.SqlClient.SqlDataAdapter
Protected WithEvents DsNewMinAnn1 As DotIntranet.dsNewMinAnn
Protected WithEvents SqlSelectCommand1 As System.Data.SqlClient.SqlCommand
Public WithEvents imgMain As System.Web.UI.WebControls.Image
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.daMainAnn = New System.Data.SqlClient.SqlDataAdapter()
Me.SqlSelectCommand1 = New System.Data.SqlClient.SqlCommand()
Me.SqlConnection1 = New System.Data.SqlClient.SqlConnection()
Me.DsNewMinAnn1 = New DotIntranet.dsNewMinAnn()
CType(Me.DsNewMinAnn1, System.ComponentModel.ISupportInitialize).BeginInit()
'
'daMainAnn
'
Me.daMainAnn.SelectCommand = Me.SqlSelectCommand1
Me.daMainAnn.TableMappings.AddRange(New System.Data.Common.DataTableMapping() {New System.Data.Common.DataTableMapping("Table", "GetDeptMainAnnouncement", New System.Data.Common.DataColumnMapping() {New System.Data.Common.DataColumnMapping("AnnouncementID", "AnnouncementID"), New System.Data.Common.DataColumnMapping("UserID", "UserID"), New System.Data.Common.DataColumnMapping("AnnouncementTitle", "AnnouncementTitle"), New System.Data.Common.DataColumnMapping("AnnouncementAbstract", "AnnouncementAbstract"), New System.Data.Common.DataColumnMapping("AnnouncementBody", "AnnouncementBody"), New System.Data.Common.DataColumnMapping("AnnouncementCreateDate", "AnnouncementCreateDate"), New System.Data.Common.DataColumnMapping("DisplayOrder", "DisplayOrder"), New System.Data.Common.DataColumnMapping("ToDisplay", "ToDisplay"), New System.Data.Common.DataColumnMapping("PictureLocation", "PictureLocation"), New System.Data.Common.DataColumnMapping("UserFirstName", "UserFirstName"), New System.Data.Common.DataColumnMapping("UserLastName", "UserLastName")})})
'
'SqlSelectCommand1
'
Me.SqlSelectCommand1.CommandText = "[GetDeptMainAnnouncement]"
Me.SqlSelectCommand1.CommandType = System.Data.CommandType.StoredProcedure
Me.SqlSelectCommand1.Connection = Me.SqlConnection1
Me.SqlSelectCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@RETURN_VALUE", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.ReturnValue, False, CType(10, Byte), CType(0, Byte), "", System.Data.DataRowVersion.Current, Nothing))
Me.SqlSelectCommand1.Parameters.Add(New System.Data.SqlClient.SqlParameter("@AnnouncementType", System.Data.SqlDbType.VarChar, 50))
'
'SqlConnection1
'
Me.SqlConnection1.ConnectionString = "data source=X-2000;initial catalog=Intranet;integrated security=SSPI;persist " & _
"security info=False;workstation id=X4355-2000;packet size=4096"
'
'DsNewMinAnn1
'
Me.DsNewMinAnn1.DataSetName = "dsNewMinAnn"
Me.DsNewMinAnn1.Locale = New System.Globalization.CultureInfo("en-US")
Me.DsNewMinAnn1.Namespace = "http://www.tempuri.org/dsNewMinAnn.xsd"
CType(Me.DsNewMinAnn1, System.ComponentModel.ISupportInitialize).EndInit()
End Sub
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
Private strPictureLocation As String
Public Property PictureLocation() As String
Get
Return strPictureLocation
End Get
Set(ByVal Value As String)
strPictureLocation = Value
End Set
End Property
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim PageName = Me.Page.ToString
PageName = PageName.Substring(4, PageName.Length - 4)
PageName = PageName.Substring(0, PageName.Length - 5)
PageName = PageName.ToLower
Dim IVars As New IntranetVariables()
Select Case PageName
'Case "ministryannouncements"
' FillDS(IVars.)
Case "hr"
FillDS(IVars.parHR_MainAnn)
Case "accounting"
FillDS(IVars.parAcc_MainAnn)
Case "co"
FillDS(IVars.parComOps_MainAnn)
Case "dis"
FillDS(IVars.parDis_MainAnn)
Case "eo"
FillDS(IVars.parExec_MainAnn)
Case "it"
FillDS(IVars.parIT_MainAnn)
Case "mp"
FillDS(IVars.parMedia_MainAnn)
Case "wd"
FillDS(IVars.parWeb_MainAnn)
Case "employeeannouncements"
FillDS(IVars.parEmp_MainAnn)
Case "message_tomr"
FillDS(IVars.parTom_MainAnn)
Case "otherministryannouncements"
FillDS(IVars.parOtherMinistry_MainAnn)
Case "prayerrequests"
FillDS(IVars.parPrayer_MainAnn)
Case "scheduleofevents"
FillDS(IVars.parSchedule_MainAnn)
Case Else
FillDS("")
End Select
End Sub
Private Sub FillDS(ByVal strParms As String)
With daMainAnn
.SelectCommand.Parameters("@AnnouncementType").Value = strParms
.Fill(DsNewMinAnn1)
End With
lblTitle.DataBind()
'imgMain.DataBind()
lblName.DataBind()
End Sub
End Class
jesus4u
May 19th, 2003, 09:30 AM
'Parent.ASPX
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="accounting.aspx.vb" Inherits="DotIntranet.accounting"%>
<%@ Register TagPrefix="uc1" TagName="MainAnnouncement" Src="../MainAnnouncement.ascx" %>
<%@ Register TagPrefix="uc1" TagName="FocusItem" Src="../FocusItem.ascx" %>
<HTML>
<title>hr</title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="CODE_LANGUAGE" content="Visual Basic 7.0">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<LINK href="../Styles.css" type="text/css" rel="stylesheet">
<script language="javascript" src="../resources/sniffer.js" type="text/javascript"></script>
<script language="javascript" src="../resources/custom.js" type="text/javascript"></script>
<script language="javascript">
<!--
varAppend = "../"
baseHREF = "../resources/";
//-->
</script>
<script language="javascript" src="../resources/style.js" type="text/javascript"></script>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<!-- BEGIN HEADER -->
<asp:Label id="lblDept" style="LEFT: 162px; POSITION: absolute; TOP: 124px" runat="server" Width="185px" Height="26px" CssClass="DeptHeader">Accounting</asp:Label><IMG style="LEFT: 162px; WIDTH: 294px; POSITION: absolute; TOP: 150px; HEIGHT: 1px" height="1" src="../images/defaul3.gif" width="294">
<TABLE id="Table1" style="LEFT: 558px; POSITION: absolute; TOP: 142px" cellSpacing="1" cellPadding="1" width="214" border="0">
<TR>
<TD>
<uc1:FocusItem id="FocusItem1" runat="server"></uc1:FocusItem></TD>
</TR>
</TABLE>
<TABLE id="Table2" style="LEFT: 166px; POSITION: absolute; TOP: 163px" cellSpacing="1" cellPadding="1" width="300" border="0">
<TR>
<TD>
<uc1:MainAnnouncement id="MainAnnouncement1" runat="server"></uc1:MainAnnouncement></TD>
</TR>
</TABLE>
<table cellSpacing="0" cellPadding="0" width="778" border="0">
<tr>
<td vAlign="top" align="left" width="618"><IMG src="../images/header-beacon.jpg" border="0"></td>
<td vAlign="top" align="left" width="160"><IMG src="../images/ani-lighthouse.gif" border="0"></td>
</tr>
<tr>
<td vAlign="top" align="left" width="778" background="../images/header-rule.gif" colSpan="2" height="35">
<table height="35" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td width="100%" colSpan="2" height="10"></td>
</tr>
<tr>
<td width="76%" height="25"></td>
<td vAlign="center" align="left" width="24%" height="25"><font face="Arial" color="#000080" size="2">
<asp:Label id="lblDate" runat="server" Width="148px"></asp:Label></font></td>
</tr>
</table>
</td>
</tr>
</table>
<!-- END HEADER -->
<script language="javascript" src="../resources/menu.js" type="text/javascript"></script>
</form>
</body>
</HTML>
'PArent ASPX Code Behind
Imports DotIntranet.MainAnnouncement
Public Class accounting
Inherits System.Web.UI.Page
Protected WithEvents lblDate As System.Web.UI.WebControls.Label
Protected WithEvents lblDept As System.Web.UI.WebControls.Label
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
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
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim MainAnnouncement1 As MainAnnouncement
lblDate.Text = Today.ToLongDateString
'Here we get the data necessary to fill the User Coctrol via properties.
MainAnnouncement1.imgMain.ImageUrl = "test"
End Sub
End Class
jesus4u
May 19th, 2003, 09:34 AM
Refresh your screen. I colored the code in question in RED.
jesus4u
May 19th, 2003, 09:48 AM
You know even if I reference it this way I still get the same error?
Imports DotIntranet.MainAnnouncement
Public Class accounting
Inherits System.Web.UI.Page
Protected WithEvents lblDate As System.Web.UI.WebControls.Label
Protected WithEvents lblDept As System.Web.UI.WebControls.Label
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
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
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
Dim MainAnnouncement1 As New DotIntranet.MainAnnouncement()
lblDate.Text = Today.ToLongDateString
'Here we get the data necessary to fill the User Coctrol via properties.
MainAnnouncement1.imgMain.ImageUrl = "test"
End Sub
End Class
Cander
May 19th, 2003, 10:04 AM
Ok what the problem seems to be is that Page does not expose the User Control. So I think you may need to dynamically load the control from the class.(ie remove the <ucr1:myControl blah/> part.
And in code behind you can load the ascx
Dim blah As MainAnnouncement = LoadControl("MainAnnouncement.ascx")
then you should be able to do what you need.
jesus4u
May 19th, 2003, 10:56 AM
I don't know why but a friend of mine suggested declaring it this way and it works now.
Protected MainAnnouncement1 As New MainAnnouncement()
jesus4u
May 19th, 2003, 10:58 AM
Here is my friend's explanation.
You must use the object id in the html code of the aspx hosting page.
For example, a control named mycontrol will be given an id "Mycontrol1".
In the code behind page, declare a protected member of mycontrol named
Mycontrol1.
protected mycontrol Mycontrol1;
....
Mycontrol1.Name = "Test";
Cander
May 19th, 2003, 10:59 AM
Originally posted by jesus4u
I don't know why but a friend of mine suggested declaring it this way and it works now.
Protected MainAnnouncement1 As New MainAnnouncement()
weird. Shouldnt make a difference I would have thought.. Oh well. :cool:
jesus4u
May 19th, 2003, 11:00 AM
Originally posted by Cander
weird. Shouldnt make a difference I would have thought.. Oh well. :cool:
:cool: and thanks for your help as usual ...;)
jesus4u
May 19th, 2003, 11:01 AM
This is getting fun :D
Cander
May 19th, 2003, 11:03 AM
Originally posted by jesus4u
This is getting fun :D
:p
Magiaus
May 21st, 2003, 08:30 PM
i am so very confused all i have to say is -> The Protected keyword confers protected access on one or more declared programming elements. Protected elements are accessible only from within their own class or from a derived class. Protected access is not a superset of friend access.
The Protected keyword can be used in conjunction with the Friend keyword in the same declaration. This combination confers both friend and protected access on the declared elements, so they are accessible from the same assembly, from their own class, and from any derived classes.
or is it something i missed.... oh Cander that Poke thing is distracting man i kept lossing track of what I was reading cause i was afraid it was going to poke me
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.