How can I use 2 variables in a class?

  • Thread starter Thread starter Shapper
  • Start date Start date
S

Shapper

Hello,

How can I use a var1 and var2 in class ItemTemplate?
Basically, I need var1 and var2 which are declared on page load to be
avalaible in Class ItemTemplate when it's called.

Public Class webform

Inherits System.Web.UI.Page
...
Private Sub Page_Load(...) Handles MyBase.Load
...
Dim var1 As String = "A"
Dim var2 As String = "B"
column.ItemTemplate = CreateItemTemplate()
...
End Sub

Function CreateItemTemplate() As ITemplate
Return New ItemTemplate
End Function

End Class

Class ItemTemplate
...
End Class

Thanks,
Miguel
 
The recognized way to pass values from page to page is in the session. For
variables on a page you can use the view state.

Am i missing your intent here?

--
Bob Powell [MVP]
Visual C#, System.Drawing

Ramuseco Limited .NET consulting
http://www.ramuseco.com

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.
 
Shapper,

See inline
Public Class webform

Inherits System.Web.UI.Page
...
Private Sub Page_Load(...) Handles MyBase.Load
...
Dim var1 As String = "A"
Dim var2 As String = "B"

column.ItemTemplate = CreateItemTemplate(var1, var2)
...
End Sub

Function CreateItemTemplate(byval whatever as string, byval whatelse as
string) As ITemplate

Return New ItemTemplate((whatever, whatelse)
End Function

End Class
Class ItemTemplate

public sub new(byval a as string, b as string)
mystringa = a
mystringb = b
end sub
...
End Class

I hope this helps,

Cor
 
Back
Top