0

I am using Visual Basic. I have a label in the master page. From the click of a button (that's on another page), I want to write code that will change the text property of this label in the master page.

I have a master page called Site.Master and all I want to do is something like:

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
  Me.Master.Page.Label.Text = "new text" 'Of course this NOT right.
End Sub

(What I've placed inside there is just pseudo code.)

Jon Adams
  • 24,464
  • 18
  • 82
  • 120
Ndumiso
  • 220
  • 4
  • 13
  • Possible duplicate of [how to access master page control from content page](http://stackoverflow.com/questions/15573505/how-to-access-master-page-control-from-content-page) – techspider Sep 09 '16 at 14:47
  • I don't get the "that's on another page" part. Are you trying to change the value from different pages? You could add a method in your master page and call it. CType(Me.Page.Master, MasterPageClass).ChangeLabel("new text") – the_lotus Sep 09 '16 at 15:17
  • @THE_LOTUS Thanks man. It worked – Ndumiso Sep 09 '16 at 16:12

1 Answers1

0

in C#

((Label)this.Page.Master.FindControl("yourLable")).Text = "new text";
Tasos K.
  • 7,979
  • 7
  • 39
  • 63