Home page

I need to ask if I have a master page containing a button as an example, then I add a new web form (default) and I designate that master page as the default form master page. Question: can I change the button text in the default page code?

+1


a source to share


3 answers


sure you can do it anyway ...

you should see videos of MAster Pages, you will see how to do it and much more!



Video # 12 MasterPages 16 minutes, 2 seconds

Video number 36 How do I: work with main pages declaratively and programmatically 29 minutes, 49 seconds

Video # 37 How Do I: Handle Events on the Main and Content Page 23 minutes, 26 seconds

+4


a source


I would use a property on the master page to change the button, I think you can make it public, but meh.

public String ButtonText { get { return button1.text; } set { button1.Text = value } }

      

Then, on the default page, set the wizard type.

<%@ MasterType VirtualPath="~/mymaster.master"  %>

      



Then on the default page you will be able to access it by going through the property.

Master.ButtonText = "Hello, Master Page Button";

      

[Sorry assuming C #]

+1


a source


If you put MasterType directive in your default page

<%@ MasterType VirtualPath="~/Master1.master" %>

      

then you can call methods and properties on the master page in code:

MyButton.Text = "New text";

      

For more information see ASP.Net 2.0 - Main Pages: Tips, Tricks, and Pitfalls

0


a source







All Articles