左右间

行走在左右之间

博客园 首页 新随笔 联系 订阅 管理
  38 Posts :: 0 Stories :: 26 Comments :: 1 Trackbacks

2008年5月29日 #

通过SPList.Update()可以更新一个List,但一般你是不能直接调用此方法的,会出现“Updates are currently disallowed on GET requests. To allow updates on a GET, set the 'AllowUnsafeUpdates' property on SPWeb.”

解决方法有两个:
1。设置 AllowUnsafeUpdates = true.这是个很取巧的方法,不只这里可以使用,在由于其他一些原因导致以上错误的时候只要设置此值,错误就可避免。我看到过有些工程里只要涉及到SPWeb,必设置此值。但是它是有安全隐患的,具体解释可以参考MSDN。

2。 不要使用Get requests而使用 Post requests,配合使用RunWithElevatedPrivileges,也可以有效解决这个问题。所谓不要使用Get requests而使用 Post requests,简单的说就是你不要直接在Page_Load这种事件里去Update list,你可以放一个Button,使用它来触发事件。然后把Update 代码放在RunWithElevatedPrivileges中执行。
string url = SPContext.Current.Site.Url;
            SPSecurity.RunWithElevatedPrivileges(delegate()
            {
                using (SPSite site = new SPSite(url))
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        SPList list = web.Lists[ListName];
                        list .Update();
                    }
                }
            }
            );

一般情况下都能满足需要。

posted @ 2008-05-29 15:06 左右间 阅读(246) | 评论 (1)编辑

2008年5月5日 #

首先在VS2008中新建一个silverlight工程,假定叫Test打开它。
一般默认会有四个文件,App.xaml,App.xaml.cs,Page.xaml,Page.xaml.cs.App.xaml 文件一般用来声明可在整个应用中共享的资源。App.xaml的后台Application类可用来处理应用级的事件,象Application_Startup, Application_Exit 和Application_UnhandledException。
在App.xaml中,
<Application x:Class="Test.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    StartupUri="XXX.xaml">
    <Application.Resources>    
    </Application.Resources>
</Application>

x:Class="Test.App"指定了对应此XAML文件的后台类,格式为ProjectName.ClassName,
StartupUri="Page.xaml"指定了启动时加载的第一个xaml文件,这里是Page.xaml.

在Page.xaml中,
<Window x:Class="Test.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="MainPage" Height="300" Width="300">
    <Grid>
    </Grid>
</Window>

x:Class="Test.MainPage"与上面的意思一样。

posted @ 2008-05-05 13:58 左右间 阅读(51) | 评论 (0)编辑

2008年4月29日 #

有时在使用VS.NET做一些操作时,由于当前用户权限不够,所以会出错,这时可以单独在启动VS时,右击VS图标,然后选择“Run as ......)”然后用相应的用户名和密码登陆就可以了。
posted @ 2008-04-29 15:15 左右间 阅读(19) | 评论 (0)编辑

2008年4月28日 #

有时我们在WebPart中需要的一些信息要在运行时才能获取,这时使用Web Part中的Tokens就会让我们的代码更加优美.

比如,我们要在WebPage中加一个TextBox,显示当前的User的logonName,WebPart的Control ID,以及相关的Class resource path,

你当然可以在运行时拼字符串,再在最后输出的时候赋给TextBox,但是这样一方面要多写代码,容易出错。另一方面不优雅。这时你可以使用Tokens。
做法如下,
string value = this.ReplaceTokens("LogonUser: _LogonUser_||WPR: _WPR_||WPID: _WPID_");

_LogonUser_,_WPR_,_WPID_都是Sharepoint中的预定义占位符.只要调用ReplaceTokens这个函数,就会自动替换成我们想要的值。再把value赋给TextBox就好了。

posted @ 2008-04-28 15:48 左右间 阅读(201) | 评论 (0)编辑

2008年4月24日 #

首先是_path不正确,如果没有给准确的domain 或 domain controller name 在_path中, ADSI/S.DS 会尝试在当前security context中决定一个DC,这有时是错的。
尝试使用:
LDAP://yourdomain.com/DC=yourdomain,DC=com
而不是:
LDAP://DC=yourdomain,DC=com

其次有可能是applicationPool的用户需要设成AD用户,否则SecurityContext会有问题。

最后,没有释放DirectoryEntry对象(close dispose),本质上它是一个COM对象,虽然原因不清楚,但是在一个纯ASP.NET的站点中,它是有机会会被回收的,至少在访问量不大的时候不会有问题。而在一个Sharepoint站点中,就不会被回收了,所以多搜几次就不行了。

以上都不行,可以尝试在App pool的属性中设置recycling,也可以一定程度上解决这个问题。

首先创建一个组,Visitor,接着找到存放Sharepoint site文件的文件夹,赋予Visitor组对这个文件夹的访问。

posted @ 2008-04-24 09:27 左右间 阅读(60) | 评论 (0)编辑

2008年4月21日 #

如果  Microsoft Internet 信息服务 (IIS) 6.0 中没有正确地配置用于虚拟服务器的应用程序池,就可能会发生此问题。此问题可能会在存在下列一种或多种情况时发生: •应用程序池没有运行。
•应用程序池帐户使用的密码不正确。
•应用程序池帐户不是服务器上的 IIS_WPG 和 STS_WPG 这两个组的公共成员。

解决方案
要解决此问题,请按照下列步骤操作: 1.验证是否已为虚拟服务器配置了应用程序池。默认的应用程序池是 MSSharePointPortalAppPool。

请按照下列步骤来确定虚拟服务器正在使用的应用程序池。 a. 单击“开始”,指向“管理工具”,然后单击“Internet 信息服务 (IIS) 管理器”。
b. 展开“ServerName”,展开“Web 站点”,右键单击虚拟服务器,然后单击“属性”。
c. 单击“主目录”选项卡。

为虚拟服务器配置的应用程序池列在“应用程序池”框中。
d. 单击“确定”。

2.验证应用程序池帐户使用的密码是否正确。IIS 不会自动轮询 Active Directory 目录服务中的密码更改。如果应用程序池帐户是一个域帐户,其密码已过期,则在为此帐户重新指定一个新密码后,您可能会收到本文“症状”部分所描述的错误信息。

请按照下列步骤来验证应用程序池帐户所用的密码是否正确: a. 在 Internet 信息服务 (IIS) 管理器中,展开“应用程序池”。
b. 右键单击为虚拟服务器配置的应用程序池(例如,右键单击“MSSharePointPortalAppPool”),然后单击“属性”。
c. 单击“标识”选项卡。
d. 在“密码”框中,键入列在“用户名”框中的应用程序池帐户所用的密码,然后单击“确定”。
e. 在“确认密码”对话框中,再次键入密码,然后单击“确定”。

3.验证应用程序池帐户是服务器上的 IIS_WPG 组和 STS_WPG 组的成员。 
根据您的具体情况选用下列方法之一。 a. 在成员服务器上安装了 SharePoint Portal Server 的情况下: 1.单击“开始”,指向“管理工具”,然后单击“计算机管理”。
2.展开“本地用户和组”,然后展开“用户”。
3.右键单击虚拟服务器的应用程序池使用的帐户,然后单击“属性”。
4.单击“成员属于”选项卡。

验证 IIS_WPG 和 STS_WPG 是否都出现在“成员属于”列表中。如果其中之一没有列出或者两者均未列出,请根据具体情况将 IIS_WPG 组、STS_WPG 组或者这两个组添加到列表中。

b. 在域控制器上安装了 SharePoint Portal Server 的情况下: 1.启动“Active Directory 用户和计算机”。
2.展开“用户”。
3.右键单击虚拟服务器的应用程序池使用的帐户,然后单击“属性”。
4.单击“成员属于”选项卡。

验证 IIS_WPG 和 STS_WPG 都出现在“成员属于”列表中。如果其中之一没有列出或者两者均未列出,请根据具体情况将 IIS_WPG 组、STS_WPG 组或者这两个组添加到列表中。


4.重新启动 IIS 以回收应用程序池: a. 在 Internet 信息服务 (IIS) 管理器中,右键单击“ServerName”,指向“所有任务”,然后单击“重新启动 IIS”。
b. 单击“在 ServerName 上重新启动 Internet 信息服务”,然后单击“确定”。

posted @ 2008-04-21 13:40 左右间 阅读(323) | 评论 (0)编辑

以VideoPlayer为例,在mxml文件中,你可以使用bottom,top,let,right之类的属性去限制他,但是当你回到as文件中的时候,你会发现VideoPlayer对象是没有那些属性的。强行使用会报错。
秘密在setStyle和clearStyle这两个函数中,
startButton.setStyle("top",0);
startButton.setStyle("left",0);
如果要取消掉一个属性的设置,可以使用:
startButton.clearStyle("bottom");

虽然不是什么大问题,但是也确实困扰了我一段时间。

posted @ 2008-04-21 10:27 左右间 阅读(107) | 评论 (0)编辑

2008年4月14日 #

[Guid("288802c4-4dfe-45b6-bb28-49dda89ec225")]
    public class MyWebPartVerb:WebPart
    {
        //通过重载这个属性可以添加自定义的Verbs.
        public override WebPartVerbCollection Verbs
        {
            get
            {
                //这是一个触发JavaScript事件的WebPart.
                WebPartVerb objFirst = new WebPartVerb("FirstVerbId","alert('XXXXXXX!');");
                objFirst.Text = "first verb text";
                objFirst.Description = "first verb description";
                objFirst.ImageUrl = "_layouts/images/loisandclark/favicon.gif";

                //这是一个触发Server端事件的WebPart.
                WebPartVerb objSecond = new WebPartVerb("SecondVerbId",new WebPartEventHandler(SecondVerbHandler));
                objSecond.Text = "second verb text";
                objSecond.Description = "second verb description";
                WebPartVerb[] objVerbs = new WebPartVerb[] {objFirst, objSecond};

                //在这里,我们保留原有的Verbs.
                WebPartVerbCollection objVerbCollection = new WebPartVerbCollection(base.Verbs, objVerbs);
                return objVerbCollection;
            }
        }

        protected void SecondVerbHandler(object sender, WebPartEventArgs args)
        {
            //Do something...
        }
    }

posted @ 2008-04-14 16:30 左右间 阅读(291) | 评论 (0)编辑

2008年4月8日 #

首先假设你收藏了www.google.com这个网址。那么你可以给你收藏的网址加快捷键。
在工具栏中,选中Bookmarks ->Organize Bookmarks...->右击你想要加快捷键的链接->Properties->在弹出窗口中,有Keyword属性,假设我们设为g,那么下次只需在地址栏中打个g,就可以直接访问www.google.com这个网址了。

你还可以给你收藏的网址加参数。还是以www.google.com为例,比如,我们每次搜索时,他使用的链接都是www.google.com/Search?q="关键字"。在FireFox中,我们可以使用%s来作为一个参数变量。比如我们修改刚才收藏的www.google.com,改为www.google.com/Search?q=%s,快捷键依然为g,那么下次你只需在地址栏中写“ g  左右间“,他就和你先访问www.google.com,在搜索框中输左右间,在按搜索键是一样的。
posted @ 2008-04-08 09:11 左右间 阅读(117) | 评论 (0)编辑

2008年4月7日 #

首先创建两个站点,主站点名字叫 Search, 在它下面有一个子站点, 名字叫Search_111。
 
在主站点的 default page中,SearchBox有三个选项:
  • All sites:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&s=All Sites
  • This site: Search:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&cs=This Site&u=http://localhost:6325
  • People:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&s=People
在主站点的List中:

在Shared Documents list中, 他有4个选项.

  • All sites:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&s=All Sites
  • People:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&s=People
  • This site: Search:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&cs=This Site&u=http://localhost:6325
  • This List:Shared Documents:http://localhost:6325/_layouts/ OSSSearchResults.aspx?k=c&cs=This List&u=http://localhost:6325/Shared Documents
 
在子站点的 default page中.
  • All sites:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&s=All Sites
  • This site: Search_111:http://localhost:6325/MMM/_layouts/ OSSSearchResults.aspx?k=c&cs=This Site&u=http://localhost:6325/MMM
  • People:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&s=People
在子站点的Task List 中的选项如下:
  • All sites:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&s=All Sites
  • This site: Search_111:http://localhost:6325/MMM/_layouts/ OSSSearchResults.aspx?k=c&cs=This Site&u=http://localhost:6325/MMM
  • People:http://localhost:6325/_layouts/OSSSearchResults.aspx?k=c&s=People
  • This List:Task:http://localhost:6325/MMM/_layouts/OSSSearchResults.aspx?k=c&cs=This List&u=http://localhost:6325/MMM/Lists/Tasks
 所以,我猜测他在使用Url传递参数的时候,有两个规则:

Rule1:所有的 search box 包含三项, People, All sites 和 This Site: site name. 如果是 People 或 All sites, 参数为 k=keyword 和s= the scope(All sites or People).如果是This Site: site name,参数为 k=keyword, cs=This Site, u=current site's url.
 
Rule2: 如果当前是在一个List里面,他将包含另外一项, This List: List name. 参数为 k=keyword, cs=This List, u=current list's url.

但是在List里面没有Url这一项,

一些 list's 属性.
Documents->Shared Documents
ParentWeb.Url:   http://localhost:6325
ParentWebUrl:   /
DefaultViewUrl:   /Shared Documents/Forms/AllItems.aspx
Description:   Share a document with the team by adding it to this document library.
Direction:   none
SendToLocationUrl:   
SendToLocationUrl:   
Title:   Shared Documents
 
Lists->Tasks
ParentWeb.Url:   http://localhost:6325
ParentWeb.Url:   /
DefaultViewUrl:   /Lists/Tasks/AllItems.aspx
Description:   Use the Tasks list to keep track of work your team needs to complete.
Direction:   none
SendToLocationUrl:   
SendToLocationUrl:   
Title:   Tasks
 
Lists->Calendar
ParentWeb.Url:   http://localhost:6325
ParentWeb.Url:   /
DefaultViewUrl:   /Lists/Calendar/calendar.aspx
Description:   Use the Calendar list to keep in, deadlines, and other important events.
Direction:   none
SendToLocationUrl:   
SendToLocationUrl:   
Title:   Calendar
 
Sub Lists->Document
ParentWeb.Url:   http://localhost:6325/MMM
ParentWebUrl:   /MMM
DefaultViewUrl:   /MMM/Shared Documents/Forms/AllItems.aspx
Description:   Share a document with the  document library.
Direction:   none
SendToLocationUrl:   
SendToLocationUrl:   
Title:   Shared Documents

我发现他有两个属性, DefaultViewUrl 和 Title, 所以我们可以通过这两个属性把它拼出来.
posted @ 2008-04-07 16:48 左右间 阅读(353) | 评论 (0)编辑