I'm trying to create a page where the logged in user can add articles to the database by getting the CurrentUserId.
But I'm getting an error regarding the html tags.
This is my code
<div class="wrapper col2">
<div id="featured_slide">
<div id="featured_content">
<h2>Add Article</h2>
<div class="">
<form action="" method="post" class="">
@{
if (IsPost)
{
var articleTitle = Request["Title"];
var articleBody = Request["Body"];
var userID = @WebSecurity.CurrentUserId;
var articleDate = DateTime.Now;
var db = Database.Open("ContosoKaratePRM");
db.Execute("INSERT INTO Articles(ArticleDate, ArticleTitle, ArticleBody, UserID) VALUES (@0, @1, @2, @3) Where UserID=@0", articleDate, articleTitle, articleBody, userID);
// @: "Contact Record was Inserted."
}
else {
<fieldset>
<dl>
<dt><label for="articletitle">Article Title</label></dt>
<dd><input type="text" name="Title" id="" size="54" /></dd>
</dl>
</dl>
<dl>
<dt><label for="comments">Article Body:</label></dt>
<dd><textarea name="Body" id="comments" rows="25" cols="45"></textarea></dd>
</dl>
<dl class="submit">
<input type="submit" name="submit" id="submit" value="Submit" />
</dl>
</fieldset>
}
}
</form>
</div>
</div>
</div>
</div>
I'm getting this weird error
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Encountered end tag "fieldset" with no matching start tag. Are your start/end tags properly balanced?
Source Error:
Line 50: <input type="submit" name="submit" id="submit" value="Submit" />
Line 51: </dl>
Line 52: </fieldset>
Line 53:
Line 54: }
Source File: /AddArticles.cshtml Line: 52
And when I use @Html.Raw like this, the submit button just won't appear.
Parser Error Message: Encountered end tag "nav" with no matching start tag. Are your start/end tags properly balanced?
Source Error:
Line 110: </li>
Line 111: </ul>
Line 112: </nav>
Line 113: }
Line 114: </div>
UFO Disko
Member
51 Points
50 Posts
Encountered end tag "fieldset" with no matching start tag.
Mar 05, 2012 08:47 PM|LINK
I'm trying to create a page where the logged in user can add articles to the database by getting the CurrentUserId.
But I'm getting an error regarding the html tags.
This is my code
<div class="wrapper col2"> <div id="featured_slide"> <div id="featured_content"> <h2>Add Article</h2> <div class=""> <form action="" method="post" class=""> @{ if (IsPost) { var articleTitle = Request["Title"]; var articleBody = Request["Body"]; var userID = @WebSecurity.CurrentUserId; var articleDate = DateTime.Now; var db = Database.Open("ContosoKaratePRM"); db.Execute("INSERT INTO Articles(ArticleDate, ArticleTitle, ArticleBody, UserID) VALUES (@0, @1, @2, @3) Where UserID=@0", articleDate, articleTitle, articleBody, userID); // @: "Contact Record was Inserted." } else { <fieldset> <dl> <dt><label for="articletitle">Article Title</label></dt> <dd><input type="text" name="Title" id="" size="54" /></dd> </dl> </dl> <dl> <dt><label for="comments">Article Body:</label></dt> <dd><textarea name="Body" id="comments" rows="25" cols="45"></textarea></dd> </dl> <dl class="submit"> <input type="submit" name="submit" id="submit" value="Submit" /> </dl> </fieldset> } } </form> </div> </div> </div> </div>I'm getting this weird error
And when I use @Html.Raw like this, the submit button just won't appear.
@Html.Raw("<fieldset>") @Html.Raw("<dl>") <dt><label for="articletitle">Article Title</label></dt> <dd><input type="text" name="Title" id="" size="54" /></dd> @Html.Raw("</dl>") @Html.Raw("</dl>") @Html.Raw("<dl>") <dt><label for="comments">Article Body:</label></dt> <dd><textarea name="Body" id="comments" rows="25" cols="45"></textarea></dd> @Html.Raw("</dl>") @Html.Raw("<dl class=\"submit\">") <input type="submit" name="submit" id="submit" value="Submit" /> </dl> @Html.Raw("</fieldset>")Mikesdotnett...
All-Star
154852 Points
19855 Posts
Moderator
MVP
Re: Encountered end tag "fieldset" with no matching start tag.
Mar 05, 2012 09:02 PM|LINK
That extra </dl> appears to be the problem. Remove it.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
UFO Disko
Member
51 Points
50 Posts
Re: Encountered end tag "fieldset" with no matching start tag.
Mar 05, 2012 09:20 PM|LINK
I did but the submit button still won't show.
On WebMatrix, I get a red line under <input> with the message "Element 'input' cannot be nested inside element 'dl'"
Mikesdotnett...
All-Star
154852 Points
19855 Posts
Moderator
MVP
Re: Encountered end tag "fieldset" with no matching start tag.
Mar 06, 2012 04:55 AM|LINK
That's true. You shouldn't be using definition lists in forms. You should use divs to separate blocks.
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter
UFO Disko
Member
51 Points
50 Posts
Re: Encountered end tag "fieldset" with no matching start tag.
Mar 06, 2012 05:16 PM|LINK
I'm having the same problem with another code snippet and I can't figure out how to solve it yet.
@if (WebSecurity.IsAuthenticated) { <nav> <ul> <li id="login"> <a id="login-trigger" href="#"> <span id="user-panel-check"></span> <span id="user-panel-title">Welcome, <strong>@WebSecurity.CurrentUserName</strong></span> <span id="user-panel"></span> </a> <div id="login-content"> <ul> <li><a href="#"><span>Settings</span> <img src="./images/setting.png" alt=""></a></li> <li><a href="#"><span>Help</span> <img src="./images/help.png" alt=""></a></li> <li><a href="./index.html"><span>Log Out</span> <img src="./images/logout.png" alt=""></a></li> </ul> </div> </li> </ul> </nav> } else { <nav> <ul> <li id="login"> <a id="login-trigger" href="#"> <span id="user-panel-check"></span> <span id="user-panel-title">Login</strong></span> <span id="user-panel"></span> </a> </li> </ul> </nav> }And the error is
I have tried everything, nothing worked so far.
Mikesdotnett...
All-Star
154852 Points
19855 Posts
Moderator
MVP
Re: Encountered end tag "fieldset" with no matching start tag.
Mar 06, 2012 08:13 PM|LINK
That's where the problem lies - a closing </strong> tag with no matching opening tag. Remove it or open it:
Beginning ASP.NET Web Pages with WebMatrix | My Site | Twitter