SSRS Custom Code to Get Textbox Name

Here’s a simple SSRS function that will get you the textbox name.

Public Function TextBoxName(ByVal meString As String) As String
Dim s As Integer = 19
Dim e As Integer = meString.IndexOf(“_TextBoxExprHost”) – 19
TextBoxName = meString.Substring(s,e)
End Function

Expression:
=Code.TextBoxName(Me.ToString)

‘Me’ is the object you are ‘in’… and Me.ToString returns the following:

“ReportExprHostImpl+[TextBoxName]_TextBoxExprHost+Paragraph00_ParagraphExprHost+TextRun00_TextRunExprHost”

Our custom code extracts the Textbox Name from the Me string.

————————————————————–



Report > Report Properties > Code

1

Add the expression where you need it… i.e. maybe you need to dynamically change the¬†background¬†color of all textboxes in a table, or set the hidden property.

2

Here’s the output:

3

Leave a Reply

Your email address will not be published. Required fields are marked *