I am trying to create a blog which hardly has 3 pages
1)EnterPost.aspx(To Enter a Post)
2)Posts.aspx(To display all the posts datewise)
3)Comments.aspx(Which displays a full post including comments)
Now when user clicks on a post title it will redirect him
to comments.aspx where he can see full post and comment on it.
Example: Path is
1)http://localhost:3214\MyBlog\comments.aspx?postid=1
2)http://localhost:3214\MyBlog\comments.aspx?postid=2
我想要的是而不是 comments.aspx?postid=?.我想将 url 名称显示为帖子的标题。
例子:
1)\MyBlog\ {帖子标题}.aspx
In Comments.aspx on Page_Load()
int id=int.Parse(Request.QueryString["pid"].ToString());
string str = "select * from posts where postid='" + id + "'";
dv_post.DataSource = DbHelper.getdata(str);
dv_post.DataBind();
在 Posts.aspx 中
protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
Literal l = (Literal)e.Item.FindControl("Literal1");
if (l.Text.Length > 100)
{
l.Text = l.Text.Substring(0, 400) + "<a href=comments.aspx?pid="+ DataBinder.Eval(e.Item.DataItem ,"postid")+">Read More</a>";
}
}