Record the learned Infopath today. After the infopath form is published to sharepoint, it will be displayed on the aspx page!
1. Infopath without code, no code written using VSTA
2. Infopath with code
Open the infopath design interface as follows: Then open "file" -- "release" -- and release it to sharepoint.
Open the form library you just released: Create a Demo and view the Demo attributes. Pay attention to the red part! BelowXmlLocationThis address will be required
Open VS and create ASP.. NET website project. In the left-side toolbox, choose items> browse> C: \ Program Files \ Microsoft Office Servers \ 12.0 \ Bin \Microsoft. Office. InfoPath. Server. dllAfter confirmation, the toolbar displays the XMLFormView control. Drag the control to the Default. aspx page.
XmlLocation: Enter the address in the second figure.
<% @ Page Language = "C #" AutoEventWireup = "true" CodeBehind = "Default. aspx. cs" Inherits = "InfoPathViewDemo. _ Default"EnableSessionState= "True"%> <% @ Register Assembly = "Microsoft. office. infoPath. server, Version = 12.0.0.0, Culture = neutral, PublicKeyToken = 71e9bce111e9429c "Namespace =" Microsoft. office. infoPath. server. controls "TagPrefix =" PC3 "%> <! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> XmlLocation= "Http: // dg-mlwang/InfoPath/Demo. xml"ShowFooter = "false" ShowHeader = "false"/> </div> </form> </body>
OK. Generate the project!
Copy the generated DLL to C: \ Inetpub \ wwwroot \ wss \ VirtualDirectories \ 80 \ bin
Copy the Default. aspx page to: C: \ Program Files \ Common Files \ microsoft shared \ Web Server Extensions \ 12 \ TEMPLATE \ LAYOUTS \ infopathDemo (the infopathDemo folder is created by yourself)
Browser navigation: http: // mossServer/_ layouts/infopathDemo/Default. aspx.
Oh, MyGod. How can this problem be solved? please Google it... Google is really powerful. It seems that many others have encountered this problem, hopefully!
Add httpmodules in web. config of the website.
<Add name = "Session" type = "System. Web. SessionState. SessionStateModule"/>
Haha, navigate to: http: // mossServer/_ layouts/infopathDemo/Default. aspx, Oh, what? The sound of Tao is still wow! It seems that the N-plus google solutions are all about using httpmodules in web. config. How can this problem be solved? Depressed, depressed!
No hope? In the afternoon, when I collapsed completely, there was no way to ask my colleagues to help me! As soon as I said it, he knew the problem at first glance. I should have asked that question! Please be ashamed to ask!
Set httpmodules in web. config.EnableSessionState= "True"Or you can configure the EnableSessionState in web. config. What a simple attribute!
Navigation again: huok is now available
The following is an infopath form containing the code written by VSTA,
First, right-click the property and choose "Duplicate property"> "display tab". Select "include footer" and write the total amount to the footer!
In the infopath form, the amount should be the quantity * unit price, and the total amount should be: sum (amount)
Right-click the text box on the right of the customer name: Write the following code for the Change event
/// <Summary> /// when the user changes, the customer address has also changed. // </summary> /// <param name = "sender"> </param> /// <param name = "e"> </param> public void UserName_Changed (object sender, xmlEventArgs e) {// write code here to change the primary data source. XPathNavigator _ username = this. mainDataSource. createNavigator (). selectSingleNode ("/my: myFields/my: UserName", NamespaceManager); // this is just an example. XPathNavigator _ address = this according to your business needs. mainDataSource. createNavigator (). selectSingleNode ("/my: myFields/my: UserAddress", NamespaceManager); _ address. setValue (_ username. value + "'address ");}
The next step is release!
Because the form code is included, it must be reviewed by the Administrator! Set full trust, tools -- form options -- security and trust
Remember, the location of the customer. xsn stored here is the path address required for uploading the form to the management center.
After the release is complete, you need to go to the management center to set up!
Navigate to management center> Application Management> management form template
The browsing address here is the address you wrote during the above release!
After the management center is set up, navigate to the activated website!
In the website concentration function, you can see the newly activated infopath form.
In the site, create a new form Library: TestDemo, and navigate to Settings> form library Settings> advanced settings. Be sure to set "allowed to manage content type" to "yes ", the default value is "no"
First, click "add from existing website content type", find the activated customer form, and add it to it (because I have already added it here, so no customer is shown here ), remember
Change the order and default content type of the "new" button, Because you add the second place by default!
In the TestDemo form library, click the new button to view the form written by customer!
When creating a new form, we found that the customer address was not changed when I entered the name. We have already written the UserName_Changed event! In addition, it is okay to test the design of the infopath form, but how can it be deployed to sharepoint?
This is because you also need to set the RESPONSE event in the attributes of the customer name text box (this is what my colleague told me )!
At this point, you canXmlLocationThis example shows how to modify attributes!
Technorati label: infopath, XmlFormView