Variable handling ASP/VB

rage2021

New member
Joined
Oct 3, 2007
Messages
2
Programming Experience
Beginner
Is it possible to declare variables in ASP then assign the variable value in VB.NET?

i.e something like
ASP
<asp:TemplateField HeaderText="@Title">
VB
Me.Title.text = "Hello"

any ideas?
 
You terminology is not quite correct. What you refer to as ASP is usually called the markup. The markup and code together make up ASP (or ASP.NET in this case).
This doesn't declare variables, but as urstop said, explain what you're trying to accomplish and we'll be able to answer the question better.
VB.NET:
<!-- Markup: -->
<asp:TemplateField HeaderText='<%# SomeFunction() %>'>

'codebehind:
Public Function SomeFunction() As String
    Return "Hello"
End Function
You can also pass variables to the Function:
VB.NET:
<!-- Markup: -->
<asp:TemplateField HeaderText='<%# SomeFunction(VariableToPass) %>'>

'codebehind:
Public Function SomeFunction(ByVal SomeVariable As String) As String
    'do something with the variable:
    If SomeVariable = "Hello" Then
        Return "Hello Stan"
    ElseIf SomeVariable = "Goodbye" Then
        Return "Daisy, Daisy"
    Else
        Return String.Empty
    End If
End Function
 
Back
Top