@{ //var PostID=Request.QueryString["Postid"];<a href="Default.cshtml"></a> int ID=0; var Post=""; var PostID=Request.Form["Search"]; if(!PostID.IsEmpty() && PostID.IsInt()) { ID=Convert.ToInt32(PostID); } var Db=Database.Open("Lesson1"); //var Post=Db.QuerySingle("Select * From BlogPosts Where ID=@0 And DatePublished<getdate()",ID); Post=Db.QuerySingle("Select * From BlogPosts Where Id=@0 And DatePublished<getdate()",ID); } <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <title></title> </head> <body> <form action="" method="post"> <label for="Search">Search:</label> <input type="search" placeholder="Enter Post ID" name="Search" value=""> <input type="submit" value="Submit"> </form> @if(Post!=null) { <div> <h1>@Post.Title</h1> <p>@Html.Raw(Post.Content)</p> </div> } else { <p>Not Blog Post Is Found</p> } </body> </html>
Post
string
var Post="";
var Post = Db.QuerySingle("Select * From BlogPosts Where Id=@0 And DatePublished < getdate()", ID);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)