Question

the problem i have is that i have multiple nested master pages:

  • level 1: global (header, footer, login, navigation, etc...)
  • level 2: specific (search pages, account pages, etc...)
  • level 3: the page itself

now, since only one form can have runat=server, i put the form at global page (so i can handle things like login, feedback, etc...).

now with this solution i'd have to also put the for example level 3 (see above) methods, such as search also on the level 1 master page, but this will lead to this page being heavy (for development) with code from all places, even those that are used on a single page only (change email form for example).

is there any way to delegate such methods from the onclick events (for example: ChangeEMail) from level 1 (global masterpage) to level 3 (the single page itself).

to be even more clear: i want to NOT have to have the method ChangeEMail on the global master page code behind, but would like to 'MOVE' it somehow to the only page that will actually use it. the reason why it currently has to be on the global master is that global master has form runat=server and there can be only one of those per aspx page.

this way it will be easier (more logical) to structure the code.

thnx (hope i explained it correctly)

have searched but did not find any general info on handling this case, usualy the answer is: have all the methods on the master page, but i don't like it. so ANY way of moving it to the specific page would be awesome. thnx

edit also part of the same thing... on the other hand - how to access the textbox1.text for example on the content page from master page? any best practice for this?

Was it helpful?

Solution

If you put the Search button and textbox on the .aspx itself (level 3) the event handler will also go in the page (or its codebehind). It doesn't matter that the form tag is on the global masterpage (level 1)

As for your second question: You can use

var tb = this.FindControl("textbox1") as TextBox;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top