Blog.aspx

1. Open Blog.aspx in Source view.

2. Just inside the Content //指conten控件type//从键盘键入 "<h2><%= MemberNameTitle %></h2>".

3. Switch to //转换Design view and drag a SqlDataSource control in the Content control//content控件. In the SqlDataSource Tasks menu click Configure Data Source.

4. For Choose Your Data Connection select GeekSpeakConnectionString, and then click Next.

5. For Configure the Select Statement check Title, Message, DateUpdated and MemberAccountName. Click Order By. For Sort by //分类,排序select DateUpdated, and then select Descending降序排列. Click OK and then click WHERE. For Column select MemberAccountName, for Operator select =, for Source select QueryString, and for QueryString field type//从键盘键入 "un". Click Add, then click OK. Verify//确认 that your dialog looks like the following. Then click Next and Finish.

6. Change the SqlDataSource ID property //属性to "blogsSqlDataSource". Drag a DataList control onto the page below the SqlDataSource control. In the DataList Tasks menu, for Choose Data Source, select blogsSqlDataSource.

Although you could use the ItemTemplate code that VWD automatically generates from//产生自 the metadata//元数据 of the selected data source, you will reuse //重复利用the ASPX source from one of the supplied User Controls //提供的用户控件to keep a consistent //始终如一的look-and-feel.

7. Switch to Source view. In the Solution Explorer, under Controls, double-click LatestBlogs.ascx. Copy everything between //在...之间the PlaceHolder control, as you see below. Switch back to Blogs.aspx and replace the existing content between the ItemTemplate tags with the copied content//拷贝的内容. Finally, change the DataList control's ID property to "blogsDataList" and set its Width property to "100%".

8. Switch to Design view. Your page should now appear as follows:

9. In the Solution Explorer, right-click Blog.aspx and select View Code. Inside the class //在类的内部add a public variable //公有变量named "MemberNameTitle" of type String//字符串类型<定义应为:public String MemberNameTitle;>. To the Page_Load event handler add the following:

C# VB  
if (Request["un"] == "lookup")
            {
            Response.Redirect("Blog.aspx?un=" + User.Identity.Name);
            }
            if (Request["un"] != null)
            {
            MemberNameTitle = Request["un"] + "'s Blogs";
            }
            

10. Press F5 to run the application. Click Member Blogs From the Master Page's main menu, and then click RodneyGuzman. Close your browser.

 

posted on 2007-04-16 15:10  改变热爱  阅读(241)  评论(0)    收藏  举报

导航