Access controls in Master Page




Access controls in Master Page
To access controls in your master pages is actually quite simple. The below example is for settings an image ImageUrl, but you can access textboxes etc, just replace image with the required field.
 
If your image in the Master Page is like below:
  1. <asp:image id="img1" runat="server" imageurl="/images/imagename.gif" />  
Then in your .aspx.vb file use the below code:
  1. Dim strImage As Image = Me.Master.FindControl("img1")   
  2. strImage.ImageUrl = "/images/newimagesfilename.gif"  
Where you see img1, that's the id of the control you are trying to access, change it as necessary.

4 people like this article, click here to say you like this article too (4)
Send a link to this page via email Send a link to this page