Publishing Infopath form on Sharepoint Pages
The msdn document at
http://msdn2.microsoft.com/en-us/ms406041.aspx
shows us how we can host our infopath form in a custom aspx page or a Windows Application.
What I would show here is how you can display your infopath form on the sharepoint page.
The hosting of infopath form on a sharepoint page can be done with either two ways :
- Using Sharepoint Designer and dropping a XMLFormView Control
- Creating a Webpart for hosting the infopath form
We will be using the second method since it is more intuitive. To develop a simple webpart for
Hosting infopath form, we will create a simple Class Library in Visual 2005 and add a reference
to Microsoft.Sharepoint
The main code we will be writing is in the CreateChildControls section.
protected override void CreateChildControls()
{
base.CreateChildControls();
try
{
control = new Microsoft.Office.InfoPath.Server.Controls.XmlFormView();
control.XsnLocation = text;
this.Controls.Add(control);
}
catch (Exception e)
{
EventLog.WriteEntry("Office", e.Message + e.Source + e.StackTrace, EventLogEntryType.Error);
}
}
In the above code, we have created a XMLFormView control programmatically. This control is in
Microsoft.Office.Infopath.Server.Controls namespace and this dll is located in Office Server directory
In Program Files directory.
In addition to it, we can use a property which can take the location of xsn file on sharepoint site to host. We will create
A property called xsn
[Browsable(true),
Category("Miscellaneous"),
DefaultValue(defaultText),
WebPartStorage(Storage.Personal),
FriendlyName("XsnLocation"),
Description("XSN Location")]
public string Xsn
{
get
{
return xsn;
}
set
{
xsn = value;
}
}
And then we can change the CreateChild controls code to take the xsn file location from the
Property like
control.XsnLocation = Xsn;
I can mail the source code to anyone if interested.
Mail me your suggestions. J
25 comments:
I am new to SharePoint development.
I read about your blog with regards to Outlook.
Can you advise how to code a simple
webpart which assigns the current user and servername to this webpart on load and display it on page.
Thanks.
Sorry for the post here, could not find a contact.
Dan wrote:
> I am trying to setup Sharepoint and it is necessary to display a
> user's calendar/tasks etc. I think this should be easy given we are
> supplied with the "My Taks", "My Calendar" Web parts etc.
>
> However it is asking for two things.
> 1) Mail Server Address
> 2)Mailbox
>
> I am ok with the first item as its just http://server_name/exchange.
> However the second item - Mailbox doesn't make much sense. This
> should be dynamic and change depending on which user is currently
> logged in!
>
> I have tried to see if there is anything i can do in the .aspx page,
> but all i see is:
> MailboxName
> xmlns="urn:schemas-microsoft-com:owapart">dalmanMailboxName
>
> Can I get this to be dynamic and change depending on the user logged
> in???
>
> Thanks,
> Dan
Hi Dan
If you are using Exchange 2007, then you are in luck. Because these webparts
behave exactly as you want with exchange 2007.
However with older versions of Exchange, what can you do is, code a simlple
webpart which assigns the current user and servername to this webpart on
load
and display it on page.
Hope this helps
--
Madhur Ahuja
hi Siva...
I have a aleady built such webpart. send me ur email and ill send you one. i have enabled my email visibility on this profile...
How to download it????
i was not able to upload the webpart.
I can mail the source code.
When the My Calendar and My Inbox webparts are used on the My Site, I can access the server and user account, but the web part is displaying the full OWA user interface (instead of just the calendar or just the inbox). Any ideas on how to get these to function correctly?
jeff,
tell me the values you are entering
for the webpart configuration.
For the My Inbox webpart:
Mail Server Address: https://mail1.lynksystems.com/exchange
Mailbox:
Jeff.Roberts
View:
Two Line
All other parameters are defaults.
Jeff,
Does ur Outlook web access opens normally?
If I browse to the OWA site (with IE), it prompts me to login and then displays the normal OWA screen. When I use this same OWA address in the My ... webparts, it browses to the same login window. In other words, the My... webpart should bypass the normal OWA screens and bring up just my calendar, or my inbox. Right?
Source code?
Dear jeff, am having the same problem regarding entering the owa credentials whenever i view mysite in the my calendar and inbox webparts, did u solve this issue?
thanks
Amer Anabtawi
i don't see the XMLFormView Control in the SharePoint Designer - how do I bring it in there?
see this
It is present in this assembly
microsoft.office.infopath.server.controls
http://msdn2.microsoft.com/en-us/library/microsoft.office.infopath.server.controls.xmlformview.aspx
Hi All,
Im working on creating a workflow initiation form for sharepoint . I
have form server 2007 installed and running with which I am browsing
the infopath forms .
my workflow.xml looks like this
<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Workflow Id="F487360C-097F-42A2-B417-95F180C23B70"
Name="OR Workflow"
Description="Orange WFs "
CodeBesideClass="OrangeWfs.Workflow1"
CodeBesideAssembly="OrangeWfs,Version=1.0.0.0, Culture=neutral,
PublicKeyToken=5e79cbf3cd5e0489"
InstantiationUrl ="_layouts/InitWf.aspx">
<MetaData>
<Instantiation_FormURN>
urn:schemas-microsoft-com:office:infopath:KoreNew:-
myXSD-2007-07-23T08-24-23
</Instantiation_FormURN>
</MetaData>
</Workflow>
</Elements>
and feature.xml looks like this
<?xml version="1.0" encoding="utf-8"?>
<Feature Id="C31B9019-27FE-4BF3-8F44-FF3B189A401A"
Title="Orange Workflows"
Description="Click to ACtivate OS WFs"
Version="1.0.0.0"
Scope="Site"
Hidden="false"
xmlns="http://schemas.microsoft.com/sharepoint/">
<ElementManifests>
<ElementManifest Location="workflow.xml" />
</ElementManifests>
<Properties>
<Property Key="GloballyAvailable" Value="true" />
</Properties>
</Feature >
for the workflow initaition I have created a InitWf.aspx that has a
webpart called xmlformview which hosts the infopath form ( some .xsn
form that has some input fields) . I have also created a class file
of this infopath from using the xsd.exe tool .
my workflow1.cs file looks like this
private void onWorkflowActivated1_Invoked(object sender,
ExternalDataEventArgs e)
{
workflowId = workflowProperties.WorkflowId;
XmlSerializer serializer = new
XmlSerializer(typeof(myFields));
if (workflowProperties.InitiationData != null)
{
XmlTextReader reader = new XmlTextReader(new
System.IO.StringReader(workflowProperties.InitiationData));
myFields initform =
(myFields)serializer.Deserialize(reader);
toname = initform.to;
fromemail = initform.from;
subject = "Test";
}
}
where myFields is the name of the class that was created from the
xsd.exe tool.
I have installed the feature and activated it for a site
colllection . Wen I activate the workflow by checking the box labelled
"Start Workflow when new Item is added " and Associate that to a
particular workflow , the workflow getts actuvated and the Page_Load
of workflow1.cs fires but the InitWf.aspx that I had created did not
even load . What could be the reason for this . At the same time when
I manually trigger the workflow the InitWf.aspx opens up and the
later on the forms gets closed the data I entered is not present in
workflow.InitiationData . It is alawys null for me
Could anyone help me in this regard . Banging my head for a long time
Akhila :)
Hi there. I am just about to email you directly Madhur regarding the webpart code to automatically add in the username for the My Inbox webpart for Sharepoint 2007. I have spent the last 3 days more or less trying everything I know to edit the existing webpart to make it do this (as it should do really by default!). I would be so greatful if you would send it to me, as I think this will be such a helpful aspect to the new Sharepoint Intranet that I am building! Many Thanks
Graham Reed, St Swithuns School, UK
Have you ever considered hosting your applications on fresh servers with fast connection speeds?
mention blogger.com and receive an extra 10% off or a free month
cheap dedicated servers and colocation
Hey guys I offer a free one month trial to check out our virtual servers. Just mention blogger.com and your in!
Scott
888-603-6333 x89
Virtual Servers Hosted
Exchange Hosting
Dedicated Server Hosting
OWItTR Hello! Great blog you have! My greetings!
UQbrb5 Your blog is great. Articles is interesting!
namNCh Wonderful blog.
ZrYReu Thanks to author.
Hello all!
Hello all!
actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.
Can I get the source code for this article? Please mail me at zacker.home@gmail.com .
Post a Comment