Showing posts with label Sharepoint Development. Show all posts
Showing posts with label Sharepoint Development. Show all posts

Wednesday, May 30, 2012

Open the Edit Form of External List from BCS Profile Page

Recently I had a business scenario, where the user wanted to use a Business data in not traditional way:

  • To find a particular entity instance with not using of search – the external system contains 20+ millions of entries, the crawl time (full and incremental) will be significant and have to be processed daily
  • To edit an entity instance with no browsing of External List – there is no way to find the particular item in the EL

Finally I designed the following solution:

  • Developed a BCS .net assembly connector in Visual Studio, which connects to Oracle database. It contains a few entities, but for simplicity we will focus on only one – Customer. It has three operations – Finder, Specific Finder and Updater and identifier UNID (string)
  • After deployment on my SPS 2010 I created a profile page in the standard way, through BDC service application’s management page in CA
  • Meanwhile I created a small configurable web part which accepts two parameters (text boxes) Customer_ID and Date (because of the business users), executes a SQL query against the Oracle and returns the UNID of the only record. The web part redirects the user to the profile page, created in the previous step. Actually this small component plays as an “item picker” which opens the item’s profile page!
  • Additionally I created an external list with view and edit forms

So, the biggest question was HOW once landed on the profile page the user can jump directly to the Edit form ??? Where is the problem? The edit form expects a parameter BcsIdentity instead of UNID and there is not a normal way to get it.

  • I added a BCS action (not external list custom action) from BDC service application’s management page in CA. Named it “EDIT” and the URL was the URL of my EditForm.aspx http://myportal/List/MyExternalList/EditForm.aspx?UNID={0}, where UNID is the identifier of my entity
  • The action is visible/accessible from the profile page. Clicking on it the user jumps to EditForm.aspx, but with wrong parameter ?UNID=123456, instead of ?ID=<BcsIdentity> and the form is empty
  • I developed a second web part, which reads the UNID parameter from the query string and encodes it in “a BCS way”

SmileSmileSmile

string unid = qstr["UNID"];
object[] identifiers = { unid };
string identifiersEnc = EntityInstanceIdEncoder.EncodeEntityInstanceId(identifiers);
string newUrl = string.Format("{0}&{1}={2}&source={3}", Page.Request.Url.ToString(),newQstrParamName, identifiersEnc, SPContext.Current.Site.Url);
Page.Response.Redirect(newUrl, true);

Finally the code redirects the browser to the same page (EditForm.aspx) but with newly added parameter ID=”myEncodedIdentifier” and the Edit form work as expected!

Special thanks to Pradeep Kamalakumar, for his significant help!

Tuesday, October 11, 2011

Ribbon Customizations and CustomActions in SharePoint 2010

In the beginning of October 2011 we did the second off-site meeting with our User Groups in Bansko (Bulgaria). Below are the slides and demo code from my presentation.


I covered the development of customizations, for SharePoint 2010 user interface, meaning custom actions, ribbon elements, notifications, statuses and dialog framework.




You could download the full Visual Studio project from here:http://db.tt/eZncKy2E


It contains an extra code for playing with bulk selection, ribbon button and modal dialog. Feel free to use it Smile


Simple ribbon button


                <!-- Simple button -->
<
CommandUIDefinition Location="Ribbon.Library.Share.Controls._children">
<
Button Id="Ribbon.Library.Share.SugbgButton"
Command="SugbgButtonCommand"
Image32by32="/_layouts/images/PPEOPLE.GIF"
LabelText="Hello SUGBG"
TemplateAlias="o1" />
</
CommandUIDefinition>


Tooltip ribbon button


                <!-- ToolTip button -->
<
CommandUIDefinition Location="Ribbon.Documents.New.Controls._children">
<
Button Id="Ribbon.Documents.New.Ribbontest"
Alt ="Test Button"
Sequence="5"
Command="RibbonTestCommand"
LabelText="Test Button"
Image32by32="/_layouts/images/QuickTagILikeIt_32.png"
TemplateAlias="o1"
ToolTipTitle="My test button tool tip"
ToolTipDescription="My tool tip description"
ToolTipShortcutKey="Ctrl-T,E"
ToolTipImage32by32="/_layouts/images/mwac_infob.gif"
ToolTipHelpKeyWord="WSSEndUser"/>
</
CommandUIDefinition>


Replace an existing ribbon button (New Folder)


                <!-- Replace a button -->
<
CommandUIDefinition Location="Ribbon.Documents.New.NewFolder" >
<
Button Id="Ribbon.Documents.New.NewFolder.MyNewFolderButton"
Alt ="Test button"
Sequence="5"
Command="MyNewFolderButtonCommand"
LabelText="New Folder"
Image32by32="/_layouts/images/menureply.gif"
TemplateAlias="o1" />
</
CommandUIDefinition>


Add ribbon button to edit form


                <!--Add a button to the edit form-->
<
CommandUIDefinition Location="Ribbon.DocLibListForm.Edit.Actions.Controls._children" >
<
Button Id="Ribbon.DocLibListForm.Edit.Actions.MySettings"
Command="EditFormButtonCommand"
Description="Go to settings"
LabelText="Site Settings"
Image32by32="_layouts/images/settingsIcon.png"
TemplateAlias="o2"
Sequence="91"/>
</
CommandUIDefinition>


All elements above are using the these handlers:



            <CommandUIHandlers>
<
CommandUIHandler Command="SugbgButtonCommand"
CommandAction="javascript:HelloRibbon();" />


<
CommandUIHandler Command="RibbonTestCommand"
CommandAction="javascript:alert('RIBBON-test was clicked');" />


<
CommandUIHandler Command="MyNewFolderButtonCommand"
CommandAction="javascript:alert('I replaced the OOB New Folder :)');" />


<
CommandUIHandler Command="EditFormButtonCommand"
CommandAction="/_layouts/settings.aspx" />
</
CommandUIHandlers>


HelloRibbon() function and related javascriptcode also could be deployed with CustomAction



    <CustomAction Id="Ribbon.Library.Actions.NewButton.Script"
Location="ScriptLink"
ScriptBlock="
function HelloRibbon()
{
alert('Hello, Ribbon Script is here!');
}
" />


Very powerful Visual Studio add-in for quick start with ribbon customizations are SharePoint 2010 Extensibility Projects and especially SharePoint Ribbon VSIX



 



Other CustomActions



    <!-- Custom Action Group in Site Settings page -->
<
CustomActionGroup
Id="MyActionGroup"
Description="This group contains all my custom actions."
Title="My Action Group"
Location="Microsoft.SharePoint.SiteSettings"
Sequence="30"
ImageUrl="/_layouts/images/mwac_textpb.gif"/>

<!--
Custom Action in Custom Action Group in Site Settings page -->
<
CustomAction
Id="MyCustomAction"
Description="This link is a custom action."
Title="My Custom Action"
GroupId="MyActionGroup"
Location="Microsoft.SharePoint.SiteSettings"
Rights="ManageWeb"
RequireSiteAdministrator="FALSE"
Sequence="20">
<
UrlAction Url="~sitecollection/_layouts/create.aspx" />
</
CustomAction>

<!--
Custom Action in Site Actions Menu -->
<
CustomAction
Id="MyNewCustomAction"
Description="This menu item is a new custom action."
Title="My New Custom Action"
GroupId="SiteActions"
Location="Microsoft.SharePoint.StandardMenu"
ImageUrl="/_layouts/images/mwac_thumbb.gif"
Sequence="10">
<
UrlAction Url="~sitecollection/_layouts/settings.aspx" />
</
CustomAction>

<!--
Adding Custom action for items in Document Library-->
<
CustomAction Id="ListMenuForMyPage"
RegistrationType="List"
RegistrationId="101"
ImageUrl="/_layouts/images/GORTL.GIF"
Location="EditControlBlock"
Sequence="105"
Title="My Page" >
<
UrlAction Url="DispForm.aspx?ItemId={ItemId}&amp;ListId={ListId}" />
</
CustomAction>


Playing with Dialogs – below is the client code which shows dialogs, using Sharepoint 2010dialog framework



<a href="javascript:showMyDialog();" id="ShaowMydialogID" style="display:inline;">
Show MyDialog
</a>


<!--Define dialog inline-->

<div id="SugbgDiv" style="display:none; padding:5px">

    <
input type="text" value="SUGBG dialog" />

    <
input type="button" value="OK" onclick="closeDialog()" />

</
div>







<!--Load Sharepoint ScriptLink-->

<SharePoint:ScriptLink ID="SPScript" runat="server" Localizable="false" LoadAfterUI="true" />







<!--Open Dialogs-->

<script language="ecmascript" type="text/ecmascript">




    var
myDialog;


    var sid;





    function showMyDialog() {


        var MyDialogDiv = document.getElementById("SugbgDiv"); MyDialogDiv.style.display = "block";





        var options = { html: MyDialogDiv, width: 200, height: 200 };


        myDialog = SP.UI.ModalDialog.showModalDialog(options);





    }





    function closeDialog() {


        myDialog.close();








</script>


You could show everything in the modal window, see how to use it to show en ExcelServices chart as image, using REST



<a href="javascript:ExcelChart();" id="ExcelChartID" style="display:inline;">
Excel MyDialog
</a>




<script language="ecmascript" type="text/ecmascript">



function ExcelChart() {
var options = { url: 'http://intranet/_vti_bin/ExcelRest.aspx/Shared%20Documents/Gears%20Sales%20History.xlsx/model/Charts(\'Chart 1\')?$format=image', width: 400, height: 400 };
myDialog = SP.UI.ModalDialog.showModalDialog(options);
}


</script>



Playing with StatusBar



<script language="ecmascript" type="text/ecmascript">



var sid;



//Status bar

function createStatusBar() {
sid = SP.UI.Status.addStatus("My status bar title", "My status bar <a href=\"#\">message<\a>", true);
}

function removeStatusBar() {
SP.UI.Status.removeStatus(sid);
}

function removeAllStatusBars() {
SP.UI.Status.removeAllStatus(true);
}

function updateStatusBar() {
SP.UI.Status.updateStatus(sid,"This is a status update");
}

function appendStatusBar() {
SP.UI.Status.appendStatus(sid,"This is appended", "This is my appended <i>status</i>");
}

function redStatusBar() {
SP.UI.Status.setStatusPriColor(sid, "red");
}

function greenStatusBar() {
SP.UI.Status.setStatusPriColor(sid, "green");
}

function blueStatusBar() {
SP.UI.Status.setStatusPriColor(sid, "blue");
}

function yellowStatusBar() {
SP.UI.Status.setStatusPriColor(sid, "yellow");
}


</script>



Notifications



<script language="ecmascript" type="text/ecmascript">



//Notifications
var notificationId;

function showNotification() {
notificationId = SP.UI.Notify.addNotification("The party has to begin after 6 hours! :)");
}

function removeNotification() {
SP.UI.Notify.removeNotification(notificationId);
}



</script>



Find the download link above to get the full VS project. Enjoy!

Tuesday, June 7, 2011

Custom web service for SharePoint

I will just publish my project online, without long explanations:

  • Target – SharePoint 2010
  • Visual Studio 2010
  • What is included:
    • Feature which is deploying demo data
    • Custom web service (asmx)
    • Class library (DLL)
    • Web Service consumer (console app)

You could get the code from here!

Enjoy

Smile

Wednesday, January 5, 2011

Sharepoint 2010: Fixing the Flyout Delay

When rolling over a number of flyouts quickly, the user sees all the flyouts shown on the screen at once which looks rubbish. 

To remove the delay altogether use this css in your page somewhere:

li.hover-off>ul

{ display:none; }

Tuesday, July 6, 2010

Telerik Components for Sharepoint 2010

In their ASP.NET AJAX Q2 Beta release, Telerik packaged RadEditor and RadGrid as standalone web parts for Sharepoint 2010.

“Need to use our AJAX controls in a custom Sharepoint 2007/2010 implementation? Not a problem at all. RadEditor, RadGrid and the rest of our ASP.NET AJAX components can also be plugged very easily into Sharepoint 2007/2010 visual/dynamic web parts, or placed directly into Sharepoint pages/user controls.”

Telerik Sharepoint 2010 Demo Site: http://sharepoint.telerik.com/Pages/default.aspx

You can play with RadGrid web part after login with:

User: .\sp2010visitor

Pass: sp2010visitor

Here http://sharepoint.telerik.com/silverlight/Pages/default.aspx you can find screen casts from Sahil Malik, how to use Telerik Silverlight controls in Sharepoint 2010, together with Sharepoint client object model. Enjoy! Smile

image

Wednesday, October 7, 2009

Sharepoint - InfoPath Error - “Some rules were not applied”

Yesterday evening I had a very strange problem with InfoPath form. When I tried deploy it to Sharepoint production farm I received the error that “some rules were not applied”. The same form worked perfect when I tested in InfoPath client against the same Sharepoint deployment. It is very important to say, that I’m using a call to UserProfileService and GetUserProfileByName operation. The production farm consist of three WFE and we found the following exception in the log:

w3wp.exe (0x15D8)                       0x17A8 Forms Server                     Forms Services Data Objects       13zh                Exception            System.Net.WebException: The remote server returned an error: (401) Unauthorized.     at System.Net.HttpWebRequest.GetResponse()     at Microsoft.Office.InfoPath.Server.SolutionLifetime.WebServiceHelper.GetResponseHelper(WebRequest request, DataAdapterTimer dataAdapterTimer, DataAdapterCredentials credentials, Stopwatch timer, ExecWebRequestExceptionState state, String adapterName, Boolean isQuery)     at Microsoft.Office.InfoPath.Server.SolutionLifetime.WebServiceHelper.ExecWebRequestSync(XPathNavigator inputSubDOM, Boolean[] inputUseDataset, XPathNavigator resultsSubDOM, Boolean resultUseDataset, XPathNavigator errorsSubDOM, Uri serviceUrl, Uri soapAction, Int64 timeOutMillisec, Solution solution, Document document, String name, Boolean isQuery, DataAdapterTimer dataAdapterTimer, DataAd...

Server platform: Windows Server 2003 x64, SP2

The solution:

Check http://support.microsoft.com/kb/926642 (Method 2: Disable the authentication loopback check) and add DisableLoopbackCheck key on each WFE.

After reboot it works!

Sunday, September 20, 2009

Attach Files to InfoPath Form, (upload to Sharepoint library and generate links into form’s body)

Soon I have a task to create InfoPath form which has Attachment control, uploads file(s) to Sharepoint library and puts a link to it in the form’s body. I will describe the steps, which a used to solve the business scenario.

I choose to use Visual Studio 2008 instead of InfoPath client and created new InfoPath Form Template project.

image

I designed a form with following layout and data source:

image

image

Field Type Description
Title Text Required, Text Box
Attachment Picture or file attachment (base64)  
group4 Repeating table Two columns, Container for hyperlinks
Url Text Text Box with conditional formatting (see the settings below)

Conditional formatting for Url text box:

image

image

image

Select a hyperlink control from Toolbox, drag and drop it in the first column of the repeating table

image

and set up the properties like this

image

Finally, double click on “Attach File” button, open “Button Properties” dialog and select “Edit Form Code”. FormCode.cs should be open, go to Solution Explorer and add a reference to Microsoft.Sharepoint.dll

Right click on the project Add/New Item…/Code/Class and enter InfoPathAttachmentEncoder.cs for file name. Copy the source code for “Create an Encoder class in Visual Studio” from http://support.microsoft.com/kb/892730 and paste it in the new created file. Make the same for InfoPathAttachmentDecoder.cs

image

Use the following lines of code to upload attached file to Sharepoint document library (“Documents”), plug a hyperlink information into form content and store the form in Form library (“MyForms”)

 

        public void btnAttach_Clicked(object sender, ClickedEventArgs e)
        {
            XPathNavigator attachmentNav = MainDataSource.CreateNavigator();

            // Get the base64 encoded attachment
            string attachedFile = attachmentNav.SelectSingleNode("//my:Attachment", NamespaceManager).Value;
            attachmentNav = attachmentNav.SelectSingleNode("//my:Attachment", NamespaceManager);
            // Delete the encoded file form XML form
            attachmentNav.InnerXml = string.Empty;

            // Get the value of "Title" field
            string reference = MainDataSource.CreateNavigator().SelectSingleNode("//my:Title", NamespaceManager).Value;

            // Convert the base64 encoded string into a byte array
            InfoPathAttachmentDecoder decoder =
              new InfoPathAttachmentDecoder(attachedFile);
            byte[] attachment = decoder.DecodedAttachment;
            string fileName = decoder.Filename;

            // Add the file as an attachment to the SharePoint list item
            using (SPSite site = SPContext.Current.Site)
            {
                if (site != null)
                {
                    using (SPWeb web = site.OpenWeb())
                    {
                        // Turn on AllowUnsafeUpdates on the site
                        web.AllowUnsafeUpdates = true;

                        // Add the attached document to "Documents" library
                        // and set the value of "Reference" column to
                        // "Title" filed of the InfoPath form

                        SPFolder lib = web.GetFolder("Documents");
                        SPFile file = lib.Files.Add(fileName, attachment, true);
                        file.Item["Reference"] = reference;
                        file.Item["Title"] = fileName;
                        file.Item.Update();
                        file.Update();

                        // Add attachment file url to "Url" field in the form
                        // by adding extra "my:group4" element in the form

                        XmlDocument xdoc = new XmlDocument();
                        xdoc.LoadXml(MainDataSource.CreateNavigator().OuterXml);

                        Uri url = new Uri(new Uri(web.Url), file.Url);

                        XmlNode grp4 = xdoc.SelectSingleNode("//my:group4", NamespaceManager);
                        XmlNode clonedNode = grp4.CloneNode(true);
                        clonedNode.SelectSingleNode("//my:Url", NamespaceManager).InnerText = url.AbsoluteUri;

                        grp4.ParentNode.InsertAfter(clonedNode, grp4);
                        string formXml = xdoc.OuterXml;
                        // Add the form to "MyForms" library
                        SPFolder formlib = web.GetFolder("MyForms");
                        string formName = string.Format("Request {0}.xml", reference);
                        SPFile form = formlib.Files.Add(formName, Encoding.UTF8.GetBytes(formXml), true);
                        form.Item["Title"] = reference;
                        form.Item.Update();
                        form.Update();

                        // Turn off AllowUnsafeUpdates on the site
                        web.AllowUnsafeUpdates = false;

                        // Close the connection to the site
                        web.Close();

                    }
                    // Close the connection to the site collection
                    site.Close();
                }
            }
        }

After publishing the form and administration approval from CA site I associated the new created Content Type with existing Form library (“MyForms”).

The results:

The initial form’s XML. <my:Attachment> inner text (the encoded file) is very big and Visual Studio hides it from the preview screen

image

The content of <my:Attachment> here is removed

image

The final form’s XML, with attached file URL

image

The empty/new form

image

The final form

image

The uploaded documents

image

The forms library

image

Download complete Visual Studio project

Friday, September 11, 2009

Sharepoint Lists vs. Database Tables

Many times I had mediations about what type of data structures to use in Sharepoint related projects – Sharepoint Lists or Database Tables. And the answer is - “Depends”! There are a lot of pros and cons about one or another approach and when I saw the “Using SharePoint Lists vs. Database Tables” article in Sharepoint Guidance (August, 2009) I decided to extend the content with my considerations. The first seven benefits are taken from the article above.

Benefit Database Sharepoint List / Library

Handles complex data relationships

Yes No

Handles large numbers of items

Yes No

Handles transactions

Yes No

Is easy to use

No Yes

Accommodates workflows

No Yes

Includes a standard interface

No Yes

Can easily add binary data

No Yes
Handle versions and show/extract history No Yes
Modify/customize UI with standard tools (SPD 2007) Yes Yes
Easier playing with files No Yes
Can easy reuse columns definitions (incl. inheritance) – Content Types No Yes
Easy integration with Office client applications – Excel export and Document information panel, using standard UI No Yes
Web Services access No Yes

Thursday, August 13, 2009

Troubles with CustomList Feature (OOB)

This evening I spent 40 minutes fighting with one my little mistake :-) I was playing with site and lists definitions from retract-solVSeWSS 1.3, and I created a custom list definition with name “CustomList”. When I deployed this def. for the first time, VS said there is a conflict with existing feature, named CustomList and I quickly decided to retract the existing one :-) But, exactly at this moment I tried to access my site collection and received the following error:

 

 

Dependency feature with id 00bfea71-de22-43b2-a848-c05709900100 for feature 'TeamCollab' (id: 00bfea71-4ea5-48d4-a4ad-7ea5c011abe5) is not installed.   at Microsoft.SharePoint.SPFeatureCollection.CheckFeatureDependency(SPFeatureDefinition featdefDependant, SPFeatureDependency featdep, Boolean fActivateHidden, Boolean fForce)

WTF?

image

And after 30 minutes investigation, I found the following:

TeamCollab feature depends on many other features, how is written in the Error message and one of them is CustomList

image

When I retracted CustomList, the server retracted it’s OOB feature and I found that feature.xml file from hive 12 \TEMPLATE\FEATURES\CustomList is missing. The fastest solution for me was to get the particular file from another Sharepoint farm and to copy it to the right place. Finally I ran

stsadm –o installfeature –name CustomList

… and all was OK

:-)

Saturday, July 25, 2009

Get Sharepoint List (or Library) Properties

I’m sharing this simple and useful tool with you, it returns info about Sharepoint list or library: List ID (GUID), List Author (Created by), Created Date, Has or not unique role assignments, List is hidden or not, Item count

Get the “EXE” from link below

Command line parameters:

image

Do not forget to run the tool with appropriate user (System/Farm) account, on the WFE server!

Download the Visual Studio 2008 project from here:

If you decide to run the project, don’t forget to change command line arguments from project properties page

image

The output:

image

Sunday, June 21, 2009

Submit InfoPath Form To Sharepoint (C#)

I would like to share this approach, because the most of people think, that the using of InfoPath forms in Sharepoint solutions is difficult for implementation and maintenance! I wish to show how the developers can use InfoPath Forms Server rendering engine as user interface for their applications!

Downloads:

The Visual Studio Project (using VSeWSS 1.3 CTP)

The form template:

Step 1: Create the form template:

1. Open InfoPath 2007 and choose to design a blank form template

image 

2. Select Tools –> Form Options and:

  • On “Compatibility” section check “Design a form template that can be opened in a browser or InfoPath”

image

  • On “Security and Trust” section uncheck “Automatically determine security level” and select “Domain”

image

3. Design the form: add layout elements, labels and controls

image

4. Configure the “Button control” actions:

  • Right click and select “Button Properties”

image

  • From Actions combo box select “Submit”

image

  • Open “Submit Options” and check “Allow user to submit this form”; select the radio button “Perform custom actions using Rules”

image 

  • Add new rule and action for it

image

  • Configure a new Submit connection

image

image

image

  • Finalize the rule configuration

image

image

image

5. Check for errors your form

image

6. Save the for as .xsn file on your local drive and open publishing wizard from File –> Publish

7. Follow the publishing steps below:

image

  • Type the URL of DSharepoint site, where InfoPath Form Services are available

image

  • Choose the last option

image

  • Specify the location, where to store the published form

image

  • Finalize the steps of publishing wizard

8. Open Sharepoint Central Administration site and navigate to Application Management -> Manage Form Templates; open “Upload Form Template” page; Browse to the location where the published form has been stored and upload it!

image

9. When the status of the form become “Ready” activate it for the preferred site collection

ip-approve

ip-approve-sc

10. As result you can find the activated form in “FormServerTemplates” library in the site collection

image

 

Step 2: Create the Visual Studio project

I’m using Visual Studio 2008 with installed VSeWSS 1.3 CTP (March 2009)

1. Create a new project, using “Web Part” template; choose “Full trust” deployment type

image

image

2. in the new project add references to these assemblies:

C:\Program Files\Microsoft Office\Office12\Microsoft.Office.Infopath.dll

C:\Program Files\Microsoft Office Servers\12.0\Bin\Microsoft.Office.InfoPath.Server.dll

image

3. Change the default name of the web part with any human readable :)

image

image

image

4. Change the target URL where you want to deploy your web part – right click on the project name and select “Properties; open debug section and change the value of “Start browser with URL”

image

5. In the .cs file of your web part add using clauses for

using Microsoft.Office.InfoPath.Server.Controls;
using System.Xml.XPath;
using System.Xml;

6. Declare the instance of XmlFormView

protected XmlFormView formView = null;


7. Instantiate the XmlFormView and add it to the web part’s controls collection



protected override void CreateChildControls()

{


    base.CreateChildControls();



    formView = new XmlFormView();

    formView.Width = System.Web.UI.WebControls.Unit.Percentage(100);


    this.Controls.Add(formView);


}



8. Override “Prerender” event of the web part; set the URL to the activated form and subscribe the instance of XmlFormView to SbmitToHost event




protected override void OnPreRender(EventArgs e)

{


    base.OnPreRender(e);



    formView.XsnLocation = "http://vm-moss-01/FormServerTemplates/Request.xsn";


    formView.ShowHeader = false;


    formView.ShowFooter = false;



    formView.EditingStatus = XmlFormView.EditingState.Editing;

    formView.SubmitToHost += new EventHandler<SubmitToHostEventArgs>(formView_SubmitToHost);



}



void formView_SubmitToHost(object sender, SubmitToHostEventArgs e)

{


    try


    {


        XPathNavigator xNavMain = formView.XmlForm.MainDataSource.CreateNavigator();


        XmlNamespaceManager manager = formView.XmlForm.NamespaceManager;



        string formContent = xNavMain.OuterXml;



    }

    catch(Exception ex)


    {


        throw new ApplicationException("RequestForm Exception", ex);


    }


}




Get the whole C# file





9. Right click on the project name and select Deploy. This functionality is avalable from VSeWSS!



vsewss-deploy



Step 3: Deployment and debugging



1. Create new page in your Sharepoint site and choose any template with web part zones :)



image



2. Open the dialog for adding of new web part



image



3. Navigate to Miscellaneous section, where you will find your new created web part; select it and click “Add” button below



image



4. The web part will show the Request Form on the page; publish the page



image



5. Switch to Visual Studio; right click on the project name; select Quick Deploy –> Attach to IIS worker process



image