Re: How to send variables to be used in a class?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Shapper wrote:
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


Unless I'm not understanding you right, I think it may be as simple as this:

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 var1 as String, ByVal var2 as string) As ITemplate
Return New ItemTemplate
End Function


End Class

Class ItemTemplate
 ...
End Class
------------

Keep in mind the local names inside CreateItemTemplate are arbitrary and don't need to match the ones being passed in (var1 and var2).

HTH,

Matt
.



Relevant Pages

  • declaring var of type
    ... string $var1; ... integer $var2; ... They aren't talking about casting. ...
    (alt.php)
  • Re: help with adding strings that are floating point numbers
    ... You said you want to add $var1 and $var2, two floating points, and get ... Using a scalar in a string operation (ex, ...
    (perl.beginners)
  • Re: saving files using a variable file name
    ... save('filename', 'var1', 'var2', ...) ... Kasey Horton wrote: ... Argument must contain a string. ...
    (comp.soft-sys.matlab)
  • Re: Not memorizing an output of a function
    ... variables var1 and var2. ... but MLint should warn the user to control this manually. ... I would probably also explain, with a short comment, why you're suppressing M-Lint ...
    (comp.soft-sys.matlab)
  • Re: [PHP] string as file
    ... This is an example of $var1 and $var2. ... I think that neither you nor Greg understands what I'm looking for. ... Use regular expressions or straight string replacements - that's the best way to implement mail-merge type behaviour. ...
    (php.general)