Hello,
I've tried a number of examples showing how to read the properties of a user
control from an aspx file where the code is on the html view of the form but
I can't figure out how to read them from the aspx.vb. Can anyone tell me
how to declare the user control in the aspx.vb file so that I can read the
properties?
I did add "Protected WithEvents UC1 As System.Web.UI.U serControl" to the
component code behind form but that's the only change I have made.
Many thanks,
Mike
Here's the example from dotnetjunkies I've been working with:
UCSub.aspc:
<%@ Control Language="vb" AutoEventWireup ="false" Src="UCSub.ascx .vb"
Inherits="UCSub " %>
<div align="center">
<table style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; FONT: 10pt
verdana; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid"
cellspacing="10 ">
<tr>
<td>
<asp:Label id="lblUserName " runat="server" Font-Bold="true" Text="User
Name:" />
</td>
<td>
<asp:TextBox id="txtUserName " runat="server" />
</td>
</tr>
<tr>
<td>
<asp:Label id="lblPassword " Font-Bold="True" Text="Password: "
runat="server" />
</td>
<td>
<asp:TextBox id="txtPassword " TextMode="Passw ord" runat="server" />
</td>
</tr>
</table>
</div>
UCSub.ascx.vb..
Public Class UCSub
Inherits System.Web.UI.U serControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
End Sub
Protected WithEvents lblUserName As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtUserName As System.Web.UI.W ebControls.Text Box
Protected WithEvents lblPassword As System.Web.UI.W ebControls.Labe l
Protected WithEvents txtPassword As System.Web.UI.W ebControls.Text Box
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
Public Sub ClearText()
txtUserName.Tex t = ""
txtPassword.Tex t = ""
End Sub
End Class
UCSub.aspx..
<%@ Register TagPrefix="DNJ" TagName="LoginC ontrol" Src="UCSub.ascx " %>
<%@ Page Language="vb" %>
<HTML>
<HEAD>
<title>Using a Sub routine in a UserControl</title>
<script runat="server">
Sub btnSubmit_Click (Sender As Object, e As EventArgs)
End Sub
Sub btnClearText_Cl ick(sender As Object, e As EventArgs)
UC1.ClearText()
End Sub
</script>
<meta name="GENERATOR " content="Micros oft Visual Studio.NET 7.0">
<meta name="CODE_LANG UAGE" content="Visual Basic 7.0">
<meta name="vs_defaul tClientScript" content="JavaSc ript">
<meta name="vs_target Schema"
content="http://schemas.microso ft.com/intellisense/ie5">
</HEAD>
<body>
<form id="form1" runat="server">
<p></p>
<DNJ:LoginContr ol id="UC1" runat="server" />
<BR>
<div align="center">
<asp:Button id="btnSubmit" text="Submit" onclick="BtnSub mit_Click"
runat="server" />
<asp:Button id="btnClearTex t" text="Clear Text"
OnClick="btnCle arText_Click" runat="server" />
<p></p>
<asp:label id="lblMessage " runat="server" />
</div>
</form>
</body>
</HTML>
UCSub.aspx.vb..
Public Class UCSub1
Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnos tics.DebuggerSt epThrough()> Private Sub
InitializeCompo nent()
End Sub
Protected WithEvents btnSubmit As System.Web.UI.W ebControls.Butt on
Protected WithEvents btnClearText As System.Web.UI.W ebControls.Butt on
Protected WithEvents lblMessage As System.Web.UI.W ebControls.Labe l
Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on
Protected WithEvents UC1 As System.Web.UI.U serControl
'NOTE: The following placeholder declaration is required by the Web Form
Designer.
'Do not delete or move it.
Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeCompo nent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'Put user code to initialize the page here
End Sub
End Class 2 3732
Got it.
Created a namespace around the user control class then added imports
[solution name].[namespace] and public [user control ID] as [user
control].ascx.vb to the aspx.vb. After declaring a public property with a
get end get in the ascx.vb I could refer to [user control ID].[property] in
the aspx.vb.
I found good information and the essence of this approach in examples at http://www.dotnetjohn.com/articles.aspx?articleid=52 and http://msdn.microsoft.com/library/de...properties.asp .
Mike
"mharness" <bo***@hotmail. com> wrote in message
news:e_******** ************@co mcast.com... Hello,
I've tried a number of examples showing how to read the properties of a user control from an aspx file where the code is on the html view of the form but I can't figure out how to read them from the aspx.vb. Can anyone tell me how to declare the user control in the aspx.vb file so that I can read the properties?
I did add "Protected WithEvents UC1 As System.Web.UI.U serControl" to the component code behind form but that's the only change I have made.
Many thanks,
Mike
Here's the example from dotnetjunkies I've been working with:
UCSub.aspc:
<%@ Control Language="vb" AutoEventWireup ="false" Src="UCSub.ascx .vb" Inherits="UCSub " %> <div align="center"> <table style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; FONT: 10pt verdana; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid" cellspacing="10 "> <tr> <td> <asp:Label id="lblUserName " runat="server" Font-Bold="true" Text="User Name:" /> </td> <td> <asp:TextBox id="txtUserName " runat="server" /> </td> </tr> <tr> <td> <asp:Label id="lblPassword " Font-Bold="True" Text="Password: " runat="server" /> </td> <td> <asp:TextBox id="txtPassword " TextMode="Passw ord" runat="server" /> </td> </tr> </table> </div>
UCSub.ascx.vb..
Public Class UCSub Inherits System.Web.UI.U serControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
End Sub Protected WithEvents lblUserName As System.Web.UI.W ebControls.Labe l Protected WithEvents txtUserName As System.Web.UI.W ebControls.Text Box Protected WithEvents lblPassword As System.Web.UI.W ebControls.Labe l Protected WithEvents txtPassword As System.Web.UI.W ebControls.Text Box
'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeCompo nent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here End Sub
Public Sub ClearText() txtUserName.Tex t = "" txtPassword.Tex t = "" End Sub
End Class
UCSub.aspx..
<%@ Register TagPrefix="DNJ" TagName="LoginC ontrol" Src="UCSub.ascx " %> <%@ Page Language="vb" %> <HTML> <HEAD> <title>Using a Sub routine in a UserControl</title> <script runat="server"> Sub btnSubmit_Click (Sender As Object, e As EventArgs)
End Sub
Sub btnClearText_Cl ick(sender As Object, e As EventArgs) UC1.ClearText() End Sub </script> <meta name="GENERATOR " content="Micros oft Visual Studio.NET 7.0"> <meta name="CODE_LANG UAGE" content="Visual Basic 7.0"> <meta name="vs_defaul tClientScript" content="JavaSc ript"> <meta name="vs_target Schema" content="http://schemas.microso ft.com/intellisense/ie5"> </HEAD> <body> <form id="form1" runat="server"> <p></p> <DNJ:LoginContr ol id="UC1" runat="server" /> <BR> <div align="center"> <asp:Button id="btnSubmit" text="Submit" onclick="BtnSub mit_Click" runat="server" /> <asp:Button id="btnClearTex t" text="Clear Text" OnClick="btnCle arText_Click" runat="server" /> <p></p> <asp:label id="lblMessage " runat="server" /> </div> </form> </body> </HTML>
UCSub.aspx.vb..
Public Class UCSub1 Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
End Sub Protected WithEvents btnSubmit As System.Web.UI.W ebControls.Butt on Protected WithEvents btnClearText As System.Web.UI.W ebControls.Butt on Protected WithEvents lblMessage As System.Web.UI.W ebControls.Labe l Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on Protected WithEvents UC1 As System.Web.UI.U serControl
'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeCompo nent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here End Sub
End Class
Got it.
Created a namespace around the user control class then added imports
[solution name].[namespace] and public [user control ID] as [user
control].ascx.vb to the aspx.vb. After declaring a public property with a
get end get in the ascx.vb I could refer to [user control ID].[property] in
the aspx.vb.
I found good information and the essence of this approach in examples at http://www.dotnetjohn.com/articles.aspx?articleid=52 and http://msdn.microsoft.com/library/de...properties.asp .
Mike
"mharness" <bo***@hotmail. com> wrote in message
news:e_******** ************@co mcast.com... Hello,
I've tried a number of examples showing how to read the properties of a user control from an aspx file where the code is on the html view of the form but I can't figure out how to read them from the aspx.vb. Can anyone tell me how to declare the user control in the aspx.vb file so that I can read the properties?
I did add "Protected WithEvents UC1 As System.Web.UI.U serControl" to the component code behind form but that's the only change I have made.
Many thanks,
Mike
Here's the example from dotnetjunkies I've been working with:
UCSub.aspc:
<%@ Control Language="vb" AutoEventWireup ="false" Src="UCSub.ascx .vb" Inherits="UCSub " %> <div align="center"> <table style="BORDER-RIGHT: 1px solid; BORDER-TOP: 1px solid; FONT: 10pt verdana; BORDER-LEFT: 1px solid; BORDER-BOTTOM: 1px solid" cellspacing="10 "> <tr> <td> <asp:Label id="lblUserName " runat="server" Font-Bold="true" Text="User Name:" /> </td> <td> <asp:TextBox id="txtUserName " runat="server" /> </td> </tr> <tr> <td> <asp:Label id="lblPassword " Font-Bold="True" Text="Password: " runat="server" /> </td> <td> <asp:TextBox id="txtPassword " TextMode="Passw ord" runat="server" /> </td> </tr> </table> </div>
UCSub.ascx.vb..
Public Class UCSub Inherits System.Web.UI.U serControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
End Sub Protected WithEvents lblUserName As System.Web.UI.W ebControls.Labe l Protected WithEvents txtUserName As System.Web.UI.W ebControls.Text Box Protected WithEvents lblPassword As System.Web.UI.W ebControls.Labe l Protected WithEvents txtPassword As System.Web.UI.W ebControls.Text Box
'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeCompo nent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here End Sub
Public Sub ClearText() txtUserName.Tex t = "" txtPassword.Tex t = "" End Sub
End Class
UCSub.aspx..
<%@ Register TagPrefix="DNJ" TagName="LoginC ontrol" Src="UCSub.ascx " %> <%@ Page Language="vb" %> <HTML> <HEAD> <title>Using a Sub routine in a UserControl</title> <script runat="server"> Sub btnSubmit_Click (Sender As Object, e As EventArgs)
End Sub
Sub btnClearText_Cl ick(sender As Object, e As EventArgs) UC1.ClearText() End Sub </script> <meta name="GENERATOR " content="Micros oft Visual Studio.NET 7.0"> <meta name="CODE_LANG UAGE" content="Visual Basic 7.0"> <meta name="vs_defaul tClientScript" content="JavaSc ript"> <meta name="vs_target Schema" content="http://schemas.microso ft.com/intellisense/ie5"> </HEAD> <body> <form id="form1" runat="server"> <p></p> <DNJ:LoginContr ol id="UC1" runat="server" /> <BR> <div align="center"> <asp:Button id="btnSubmit" text="Submit" onclick="BtnSub mit_Click" runat="server" /> <asp:Button id="btnClearTex t" text="Clear Text" OnClick="btnCle arText_Click" runat="server" /> <p></p> <asp:label id="lblMessage " runat="server" /> </div> </form> </body> </HTML>
UCSub.aspx.vb..
Public Class UCSub1 Inherits System.Web.UI.P age
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer. <System.Diagnos tics.DebuggerSt epThrough()> Private Sub InitializeCompo nent()
End Sub Protected WithEvents btnSubmit As System.Web.UI.W ebControls.Butt on Protected WithEvents btnClearText As System.Web.UI.W ebControls.Butt on Protected WithEvents lblMessage As System.Web.UI.W ebControls.Labe l Protected WithEvents Button1 As System.Web.UI.W ebControls.Butt on Protected WithEvents UC1 As System.Web.UI.U serControl
'NOTE: The following placeholder declaration is required by the Web Form Designer. 'Do not delete or move it. Private designerPlaceho lderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Init 'CODEGEN: This method call is required by the Web Form Designer 'Do not modify it using the code editor. InitializeCompo nent() End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArg s) Handles MyBase.Load 'Put user code to initialize the page here End Sub
End Class This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Sushil Srivastava |
last post by:
Hi Guys,
Would you be able to help me using C# GUI (with user interface component) in
my MFC application. I have used managed extension, COM-interops, etc but
problem is this C# component has user interface. how should have get window
handle from managed windows?
Thanks in advance.
Sushil
|
by: abjork |
last post by:
I have a aspx page with two user controls. One of them holds some properties that I would like to set from the other user control. How do I do that
I keep getting "Object reference not set to an instance of an object." when I declare the first user control like this from within the second UC
Public formStandard As PIC.FormStandar
....
formStandard.Market =
|
by: Chris |
last post by:
novice question here...
I am building a registration form while learning Asp.Net. I am having
trouble passing data between "dynamically"-added server controls.
To simplify, I have a single Registration.aspx page that contains 2
panels. Each panel is loaded with a user control during Page_Load():
protected Panel panel1;
protected Panel panel2;
|
by: Lan H. Nguyen |
last post by:
I used the technique from this article
http://msdn.microsoft.com/asp.net/using/building/webcontrols/default.aspx?pull=/library/en-us/dnaspp/html/usercontrols.asp,
that set the properties to ViewState but I have 2 problems:
1. An object reference error when I tried to set user control's property
like the article did ( the sample code from the article actually worked )
2. When I created an instance of that user control to solve the problem...
|
by: Paul |
last post by:
Hi I am trying to conditionally hide a user control on a form in the code.
There is a visible element in the properties box of the user control but in
the .vb file (in the code) the object does not seem available. Using me. the
intellsince does not show the user control name, so can not seem to get to
its properties in code.
Thanks.
Paul G
Software engineer.
| |
by: rmccinc |
last post by:
Hello-
I am missing something very easy here I think.
I have 3 files
test.master.vb (Master)
content.aspx.vb (content)
Control.ascx.vb (user Control)
|
by: jesl |
last post by:
Group,
I have created a User Control with the property "Html" of type string.
If I declare this control on an ASPX page with the value "<b>This is an
entity: <</b>" for the property "Html", the ASP.NET parser seems to
automatically convert the entity reference "<" to it's corresponding
character value "<".
For example, if the tagprefix and tagname for the user control is "dn"
and "test":
|
by: Sasquatch |
last post by:
I'm still having trouble creating a simple login page using the
asp:login
control. I followed some instructions in a WROX book, "Beginning
ASP.NET 2.0," and the instructions are very straight forward, but it
won't work for me. I've got a little better troubleshooting
information for everyone now. First, here's how I set this stuff up...
1. Created a new folder named "testlogin"
2. Turned that folder into an application using the...
|
by: tshad |
last post by:
In VB 2008, I have a user control added to the page in the PageLoad event -
but the properties are causing me an error.
The program (TakeSurveyTest.aspx) using the control (ContactInfo):
<%@ Page Language="VB" AutoEventWireup="true" Trace="true"
CodeFile="TakeSurveyTest.aspx.vb" Inherits="TakeSurveyTest" %>
....
<div visible="true" runat="server">
<asp:PlaceHolder ID="ContactInfo" runat="server"/<br />
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |