tags:

views:

110

answers:

2

How do I get value of a textbox thats placed in the masterpage?

Please help me.. Thanks.

A: 

I would find another solution. The purpose of master pages is to decouple the general layout from the specific pages (or controllers). You should be free to change the master pages without breaking the application.

Pete
+1  A: 

I agree with Pete.

Sometimes it is convenient to put general items into the master page. In contrast to classic asp.net it is harder to get the value with every post. In classic asp.net there is only one formular on the html page wich will be posted and all works well. In mvc there could be more formulars on the page. You have to put the textbox into a every form to get the value in every post - no solution.

A custom user control (ascx) might be a solution. Put the textbox in and place the custom control into the form where you need the value. If you have more forms or a complicated layout, than it is no solution.

A hidden field might be a solution. Replicate value changes of your original textbox into hidden fields placed in the formulars where you need the value.

Christian13467