422,767 Members | 1,184 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,767 IT Pros & Developers. It's quick & easy.

Why doesn’t Visual Studio Default.aspx file let me add HTML elements?

P: 74
I am confuse about why Visual Studio 2017 doesn't let me add HTML elements into the Default.aspx, but what I do know is that under the Solution Explorer, I see master page and apparently they are bind to the content page (which is the Default.aspx). Also, I put a copy of my screenshots problems.

So my question is do I start putting content (HTML elements) inside of that master page first!
Aside from what I have mentioned above, I also notice that when I try to put basic HTML elements into the @page directive (Default.aspx file), it says "“Content is not supported outside of 'script' or 'asp:Content' Regions” ".
The only reason I know of these terms is because I research this problem. Here are the articles that I have researched. "Content Not Supposed to Be Outside 'Script' or 'asp:Content' Regions" https://msdn.microsoft.com/en-us/lib...v=vs.100).aspx

Here are the screenshots of master page and default.aspx files.




Attached Images
File Type: jpg problem 1.jpg (25.7 KB, 185 views)
File Type: jpg problem 2.jpg (47.0 KB, 138 views)
Sep 2 '17 #1
Share this Question
Share on Google+
4 Replies


P: 74
@Rabbit Do you think you can help me with my problem?
Sep 2 '17 #2

Frinavale
Expert Mod 5K+
P: 9,731
A MasterPage contains the layout for your website which pages within your application can then use so that your layout is consistent.

Your master page will contain the HTML structure for your site. When you go to the pages within your site (like your Default.aspx page), the content from that aspx page will be used to populate placeholders in your MasterPage.

In your simple case, your Default.aspx uses the SiteMaster master page. This means that the Default.aspx file should NOT contain the <DOCTYPE>, <head> or <body> tags because it is already defined in your SiteMaster.
Sep 5 '17 #3

P: 74
@Frinavale,

Thanks for the advice, but I didn't even have to work with the SiteMaster file for what I was trying to accomplish. All I had to do was drag the control elements in the toolbox of VS into the Designer view of my Default.aspx file. I thought that my initial method of working with the web form was overly complicated and that was why.
Sep 5 '17 #4

Frinavale
Expert Mod 5K+
P: 9,731
Did you unhook the site from the Default.aspx file?
Or did you remove the <html> tag from your Default.aspx page?

You were getting errors (or warnings) because cannot have 2 <html> tags in your generated HTML...the pictures of the Default.aspx and SiteMaster components that you posted showed that you would have generated invalid HTML.
Sep 11 '17 #5

Post your reply

Sign in to post your reply or Sign up for a free account.