Displaying the value of a string variable in ASP.Net markup

asp.net, markup, vb.net

Solution

The way this would be accomplished is through a code behind method being called.

Something like this for C#

<h1>People Authorized to Release Children for <% =this.GetForename() %> </h1>

or this for VB.NET

<h1>People Authorized to Release Children for <% =Me.GetForename() %> </h1>

and in code behind C#

protected string GetForename() 
{
    return GridViewParentsSummary.DataKeys(GridViewParentsSummary.SelectedIndex).Values("Forename");
}

or in VB.NET

Protected Function GetForename() As String
    Return GridViewParentsSummary.DataKeys(GridViewParentsSummary.SelectedIndex).Values("Forename")
End Function

Problem

Is it possible to take the value from a string variable from a code-behind file and display it in this markup? ``` <h1>People Authorized to Release Children for <TheVariableGoesHere> </h1> ``` The variable we would like to include is called strForename. ``` Protected Sub GridViewParentsSummary_SelectedIndexChanged(sender As Object, e As EventArgs) Handles GridViewParentsSummary.SelectedIndexChanged IntParentsID = GridViewParentsSummary.DataKeys(GridViewParentsSummary.SelectedIndex).Value strForename = GridViewParentsSummary.DataKeys(GridViewParentsSummary.SelectedIndex).Values("Forename") blnAddModeIsSelected = False Response.Redirect("AuthorizationForChildReleaseDetails.aspx") End Sub ```

Original source