473,396 Members | 1,734 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how access class variable in .net

i crated calss as data.vb in vb.net and i am declaring variable public a as string
and a="ABC" and i want to use this variable value when form loaded and disply that text in lable how can i do
Nov 26 '07 #1
1 1636
i crated calss as data.vb in vb.net and i am declaring variable public a as string
and a="ABC" and i want to use this variable value when form loaded and disply that text in lable how can i do
Okay, you created a class as "data.vb" and in that class you set a public string equal to "ABC", within your code behind page for example "Default.aspx.vb" you would like to get this value and put it in a label control on page load.

ASP.NET VB.NET HTML CODE PAGE (Default.aspx)
[HTML]
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">

<title>VB.NET Class Example</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<asp:Label ID="Label1" runat="server" Text=""></asp:Label>

</div>

</form>

</body>

</html>

[/HTML]

ASP.NET VB.NET CODE BEHIND PAGE (Default.aspx.vb)
Expand|Select|Wrap|Line Numbers
  1. Partial Class _Default
  2.  
  3. Inherits System.Web.UI.Page
  4.  
  5. Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
  6.  
  7. Dim mdc As New myDataClass()
  8.  
  9. ' ADD CLASS DATA TO LABEL
  10.  
  11. Label1.Text = mdc.a.ToString
  12.  
  13. End Sub
  14.  
  15. End Class
  16.  
  17.  
ASP.NET VB.NET CLASS PAGE in App_Code folder (myDataClass.vb)
Expand|Select|Wrap|Line Numbers
  1. Imports Microsoft.VisualBasic
  2.  
  3. Public Class myDataClass
  4.  
  5. Public a As String = "ABC"
  6.  
  7. End Class
  8.  
  9.  
I hope this will helps you, please let me know if any further explination is needed.

- Aaron Sandoval
"remember: There's a thin line between good | great..."
Nov 27 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: Banaticus Bart | last post by:
I wrote an abstract base class from which I've derived a few other classes. I'd like to create a base class array where each element is an instance of a derived object. I can create a base class...
166
by: Graham | last post by:
This has to do with class variables and instances variables. Given the following: <code> class _class: var = 0 #rest of the class
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
6
by: Christian H | last post by:
Hi! I've created a custom control (myDrawControl) that deals with drawing. This control is then added to a form( myMainForm) Now, whenever something is dragged and dropped onto myDrawControl ,...
2
by: paul meaney | last post by:
All, myself and another developer have been staring blankly at a screen for the past 48 hours and are wondering just what stunningly obvious thing we are missing. We are trying to load up 2...
2
by: Corey B | last post by:
Is there a way for an instance of a custom class to access an ASPX page level variable? I know that I can access a Session variable from within a class using the following code: myClassVar =...
3
by: rick | last post by:
I have a situation where I want to write an extensible class that is capable of saving / restoring properties of classes derived from it. A simplified example is explained as follows;- class A...
7
by: Valeriu Catina | last post by:
Hi, consider the Shape class from the FAQ: class Shape{ public: Shape(); virtual ~Shape(); virtual void draw() = 0;
9
by: LamSoft | last post by:
Class B { public B() {} } Class A : B { public static string ABC = "myABC"; public A() {} }
1
by: Autostrad | last post by:
Below; I have 2 classes (forms), Namely, "PrintOneEmployee" and "DeleteOne". In class "PrintOneEmployee"; I want to declare a variable with name of "fileName" to contain the name of the file...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.