Reputation: 9
Before someone tries to answer this, let me just say that im pretty new to the world of programming and may not understand some basic stuff. That being said, ive been working on a ASP.Net application and its been going well. However every time ilink a page to my default page, i cant double click on buttons etc anymore to create event handlers(im not in debug mode)
Upvotes: 0
Views: 1049
Reputation: 49309
Hum, that does look ok.
Ok, your problem is this:
WHEN you create (add) a page WITHOUT a master page, then your "minimal" markup code will look like this:
So, now how we will place our mark up in side of the form tag as per above.
And the page would render like this:
HOWEVER, I would NOT attempt to THEN add the above page to a master page - it will be a mess.
WHEN you add a new page (but with the master choice), then the markup for that page will look like this:
Note now how BARE BONES the markup is.
You do NOT have the "form start/end" tags.
So a web page attached to a master page does NOT have all that original page layout stuff - and if it has, then it will not work. And note this:
Note the green squiggle lines - it is telling you that the mark-up is bad, and NOT allowed.
So, for a child page attached to a master? Then NONE of the form tag stuff is required, and your web page will in fact be "inserted" automatic into the master page - as a result, you ONLY are to put markup inside of the two content tags as per above. So the markup will look like this:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>This is some big text</h2>
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Content>
And the page will then render with the master page + this page like this:
so this quite much means if you ALREADY created the web page, you can not with MUCH ease THEN decide to use that web page as a master + child page combo.
If you did/do have a existing page?
I would create a NEW web page (master/child), and then cut + paste (transfer) the existing markup from that non master/child page to the new web form.
You would in theory take all the markup between teh form tags, and paste it into the content tag.
So you can't use a web form that was created as a regular page with markup, and THEN decide to attach/use that SAME web form as a child to a master page.
As you can see, a web page created as a child to master has WAY LESS markup, and it only starts out with a content tag, and you are then free to add controls etc. to that web page.
So this is not working becuase you took/have a existing web page created with all that form tag stuff, and you now trying to use that page with a master/child setup, and a web page as a child simply does not have all that extra form stuff.
I would create a new web page (master/child) select he master page, and then take a look at the markup - it will start out as noted like this:
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
<h2>This is some big text</h2>
<asp:Button ID="Button1" runat="server" Text="Button" />
</asp:Content>
And if you drag/drop controls between teh Content tags, then you can quite much double click on, and develop and work on that page just like any other page.
But just keep in mind the signficant differnce in markup between the two types of web pages - their markup is quite different as you can see, and for a child page attached to a master page - the form tags etc. does NOT exist.
Behind the scenes, the master page renders, and then the child page is injected into that page for you. And thus in theory the form start/end tags exist in the master page, and your "content" is injected automatic into that master page.
For the most part, any development in these child pages is identical to a regular (not attached to master) page, but the markup is quite a bit different to start out with.
So, no, you can't interchange a page built and attached to a master page as a separate page - and the reverse is also true.
Upvotes: 1