Pages

Wednesday, March 3, 2010

SharePoint Discussion board reply without previous posts content.

1. Open Discussion Board -> NewForm.aspx using SharePoint Designer
2. Paste following javascript code to bottom of the "MainContentPlaceHolder"

<script language="javascript" type="text/javascript">
var d = document.getElementsByTagName("textarea");
for( var i=0; i < d.length; ++i){
if( d[i].id.indexOf('TextField') != 0 ){
d[i].value = " ";
}
}
</script>



Saturday, February 20, 2010

Query XML String as a SQL Table.

This basic sample demonstrates how to read string xml data as a normal sql table.
This is very useful is you want to parse bulk data into sql server stored procedure.
For this example I am using ArrayList of my “Test” class. And using XmlSerializer I am going to convert it in to XML. For demonstration purpose I am just declare a SQL variable “@XMLString” to hold xml data.
declare @XMLString xml

set @XMLString = '?<ArrayOfTest>
<Test>
<TestID>1</TestID >
<TestName>ASP.NET Test</TestName>
<TestDuration>2 Hrs</TestDuration>
</Test>
<Test>
<TestID>2</TestID>
<TestName>SharePoint Test</TestName>
<TestDuration>2 Hrs</TestDuration>
</Test>
<Test>
<TestID>3</TestID>
<TestName>SQL Server Test</TestName>
<TestDuration>2 Hrs</TestDuration>
</Test>
</ArrayOfTest>'

Now we can perform query against @XMLString using nodes function and xpath.


select TableAlias.ColumnAlias.value('TestID[1]','VARCHAR(20)') ,
TableAlias.ColumnAlias.value('TestName[1]','VARCHAR(20)') ,
TableAlias.ColumnAlias.value('TestDuration[1]','VARCHAR(20)')

from @XMLString.nodes('//ArrayOfTest/Test')TableAlias(ColumnAlias)


Example 2:
Here is an example of little advanced filtering with XPath.

select TableAlias.ColumnAlias.value('TestID[1]','VARCHAR(20)') ,
TableAlias.ColumnAlias.value('TestName[1]','VARCHAR(20)') ,
TableAlias.ColumnAlias.value('TestDuration[1]','VARCHAR(20)')
from @XMLString.nodes('//ArrayOfTest/Test[TestID >= 2]')TableAlias(ColumnAlias)

Download Source
Click here to Read MSDN for more info

Sunday, January 10, 2010

Discussion board anonymous reply with custom view

We can achieve this requirement by adding new list view template to Discussion List, i will call it "Flat Anonymous".

Steps,

1. Open FEATURES\DiscussionsList\schema.xml

(Exact Path : Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\FEATURES\DiscussionsList\schema.xml)

(don't forget to Backup schema.xml file before doing any modifications)

2. Find PersonViewMinimal

3. Create a copy and name it PersonViewMinimalExtended

4. it should look like following

<Field ID="{b4ab471e-0262-462a-8b3f-c1dfc9e2d5fd}" Name="PersonViewMinimalExtended" DisplaceOnUpgrade="TRUE" Group="_Hidden" Filterable="TRUE" Sortable="TRUE" Type="Computed" DisplayName="$Resources:core,Posted_By;" ReadOnly="TRUE" AuthoringInfo="$Resources:core,picture_and_name;" SourceID="http://schemas.microsoft.com/sharepoint/v3" StaticName="PersonViewMinimalExtended">

<FieldRefs>
<FieldRef ID="{d31655d1-1d5b-4511-95a1-7a09e9b75bf2}" Name="Editor" />
<FieldRef ID="{adfe65ee-74bb-4771-bec5-d691d9a6a14e}" Name="PersonImage" />
<FieldRef ID="{bd2216c1-a2f3-48c0-b21c-dc297d0cc658}" Name="IsRootPost" />
</FieldRefs>

<DisplayPattern>
<Switch>
<Expr>
<Field Name="IsRootPost" />
</Expr>
<Case Value="TRUE">
<HTML><![CDATA[<table cellpadding="0" cellspacing="0"><tr><td style="padding-left: 5px;">]]></HTML>
<Field Name="PersonImage" /><HTML><![CDATA[</td></tr><tr><td style="padding-left: 5px;" nowrap>]]></HTML>
<Field Name="Editor" /><HTML><![CDATA[</td></tr></table>]]>
</HTML>
</Case>
<Default>
<HTML><![CDATA[&nbsp]]></HTML>
</Default>
</Switch>
</DisplayPattern>

</Field>





5. find $Resources:core,DiscussionViewFlat;

and create a copy from that view () .

and Change BaseViewID = "20" of newly created view

and Change display name to DisplayName="Flat Anonymous"

6. Find

from newly copied view

7. Rename it to
Now go to SharePoint site discussion board list and create new view.

Then select "Flat Anonymous" as the template.

Wednesday, November 11, 2009

Forms Authentication in SharePoint

http://msdn.microsoft.com/en-us/library/bb975136.aspx

Monday, October 26, 2009

Re-using SharePoint controls

http://community.zevenseas.com/Blogs/Robin/archive/2009/07/03/re-using-sharepoint-controls.aspx

Monday, August 24, 2009

Deep Dive into the SharePoint Content Deployment and Migration API

http://blogs.technet.com/stefan_gossner/archive/2007/08/30/deep-dive-into-the-sharepoint-content-deployment-and-migration-api-part-1.aspx