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) -
Partial Class _Default
-
-
Inherits System.Web.UI.Page
-
-
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
-
-
Dim mdc As New myDataClass()
-
-
' ADD CLASS DATA TO LABEL
-
-
Label1.Text = mdc.a.ToString
-
-
End Sub
-
-
End Class
-
-
ASP.NET VB.NET CLASS PAGE in App_Code folder (myDataClass.vb) -
Imports Microsoft.VisualBasic
-
-
Public Class myDataClass
-
-
Public a As String = "ABC"
-
-
End Class
-
-
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..."