TonyLoco23
07-22-2011, 06:53 PM
I am new to Visual Studio and am trying to use Master Pages for the first time. I was hoping that they would work similar to the Dreamweaver template.
In a Dreamweaver template you can create as many "editable regions" as you need. My common practice is to create an editable region in the "head" section of the page and another "editable region" in the body section. That way for every page I can have custom code in both the head and the body of each page, and also common code and html for all pages between the two editable regions in the head and body.
I tried to to do the same in the Visual Studio "Master Page". I created one "ContentPlaceHolder" in the head section with ID="ContentPlaceHolderHead" and another one in the body section with ID="ContentPlaceHolderBody.
In my head section I pull a variable out of the query string and connect to a database using that variable, then I need to use that database connection and variable in the body section. However none of the variables in the first ContentPlaceHolder are available in the second one, it is as if they are 2 seperate pages altogether. When I try to use a variable in the second ContentPlaceHolder that is dimmed in the first one it says it is not declared.
How can I make it so that I can have 2 editable regions in the master page that can share variables?
In a Dreamweaver template you can create as many "editable regions" as you need. My common practice is to create an editable region in the "head" section of the page and another "editable region" in the body section. That way for every page I can have custom code in both the head and the body of each page, and also common code and html for all pages between the two editable regions in the head and body.
I tried to to do the same in the Visual Studio "Master Page". I created one "ContentPlaceHolder" in the head section with ID="ContentPlaceHolderHead" and another one in the body section with ID="ContentPlaceHolderBody.
In my head section I pull a variable out of the query string and connect to a database using that variable, then I need to use that database connection and variable in the body section. However none of the variables in the first ContentPlaceHolder are available in the second one, it is as if they are 2 seperate pages altogether. When I try to use a variable in the second ContentPlaceHolder that is dimmed in the first one it says it is not declared.
How can I make it so that I can have 2 editable regions in the master page that can share variables?