wss2 如何在页面上显示登陆的用户名

本文介绍了一种在SharePoint网站上使用XSLT代码显示当前登录用户姓名的方法。通过设置DataView Web Part并调整XSLT代码实现个性化欢迎信息。
Howto: Display the Username for the Logged on user on a page

This is one of my favorites.  I want my site to say, “Hello, John Jansen, welcome to this site“ or whatever.  But since you can't author server-side code with SharePoint sites, there is no evident way to do this.  The way I get around this limitation is to code XSLT and make it do what I want.

1. Insert a Data View Web Part based on the Announcements list
2. Click on Data > Conditional Formatting
3. Select any data value and Click on Create
4. Click on Show Content
5. Create a Condition that says: Title EQUALS [Current User] and click OK back to the Design view
6. Type “Hello, welcome to this site“ inside one of the Table cells
7. Switch to Code view
8. Find the following code:
<ParameterBinding Name="UserID" Location="CAMLVariable" DefaultValue="CurrentUserName"/>
9. Change this code to this:
<ParameterBinding Name="UserID" Location="CAMLVariable;ServerVariable(LOGON_USER)" DefaultValue="CurrentUserName"/>
10. Scroll up in the code and find “Hello, welcome to this site”
11. Change this code to say this:
“Hello, <xsl:value-of select="$UserID"/> welcome to this site”
12. Save the page

Interesting notes:

First, you will see the user name repeat for each value in the Data View, so you should change the display using Data..Style so that it only shows One record.

Second, the ServerVariable() can be any of the server variables as documented on MSDN.

Third, the reason we created the Conditional Formatting in steps 2 - 5 was to make sure $UserID would be in scope.

Hope this works for ya!

-John

Published Thursday, April 29, 2004 11:33 AM by frontpoint

摘自: http://blogs.msdn.com/frontpoint/articles/123179.aspx 版权归原作者所有

转载于:https://www.cnblogs.com/joelbh/archive/2007/10/19/930308.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值