• Skip to main content
  • Skip to primary sidebar
  • Skip to footer
  • Technology
    • Development
    • Hardware
    • Intune
    • Microsoft
    • Office
    • Office 365
    • Security
    • SharePoint
    • Software
    • SQL server
  • Personal development
    • Blog
    • Career
    • Freelancer
    • Knowledge
    • NEWS
    • Private
    • Thoughts
  • Consulting services
  • Contact me

Not only IT

About life, IT and other things...

Home » Technology » SharePoint » Application pages for dummies. Part 2.

Application pages for dummies. Part 2.

October 26, 2012 By Tomasz Szulczewski 3 Comments

Finally, I was able to finish the second part of the post about SharePoint 2010 application pages. First part can be found here. At the end of the previous post you saw that for the new item we need a page for it. In my case, it’s “WorkFlow01_New.aspx”. Of course, we can imagine that the same form will be used for all tasks, but it could be to complicated and messy. Anyway, we add a new application page to the project and then we place it into “PlaceHolderMain” module following controls: 5 labels, 4 text fields, 1 calendar control, and a button. The tricky part is that we don’t have access to the graphic designer of VSTO, so we can’t see our design of the page in the fly. See below my simple page. As you can see there’s nothing fancy.

<asp:ContentID=”PageHead”ContentPlaceHolderID=”PlaceHolderAdditionalPageHead”runat=”server”>

</asp:Content>

 

<asp:ContentID=”Main”ContentPlaceHolderID=”PlaceHolderMain”runat=”server”>

<tablewidth=”1000″>

<tr>

<td><asp:LabelID=”LbInvoiceNumber”runat=”server” Text=”InvoiceNumber”> </asp:Label></td>

<td><asp:LabelID=”LbInvoiceDate”runat=”server”Text=”InvoiceDate”>

</asp:Label></td>

<td><asp:LabelID=”LbInvoiceAmount”runat=”server”Text=”InvoiceAmount”>

</asp:Label></td>

<td><asp:LabelID=”LbSupplier”runat=”server”Text=”Supplier”>

</asp:Label></td>

<td><asp:LabelID=”LbPurchaseOrder”runat=”server”Text=”PurchaseOrder”>

</asp:Label></td>

</tr>

  

<tr>

    <td><asp:TextBoxID=”InvoiceNumber”runat=”server”></asp:TextBox></td>

    <td><asp:CalendarID=”InvoiceDate”runat=”server”></asp:Calendar></td>

    <td><asp:TextBoxID=”InvoiceAmount”runat=”server”></asp:TextBox></td>

    <td><asp:TextBoxID=”Supplier”runat=”server”></asp:TextBox></td>

    <td><asp:TextBoxID=”PurchaseOrder”runat=”server”></asp:TextBox></td>

</tr>

</table>

<asp:ButtonID=”SaveToList”runat=”server”Text=”Save to list”OnClick=”SaveList”on/>

 

</asp:Content>

 

<asp:ContentID=”PageTitle”ContentPlaceHolderID=”PlaceHolderPageTitle”runat=”server”>

Application Page

</asp:Content>

 

<asp:ContentID=”PageTitleInTitleArea”ContentPlaceHolderID=”PlaceHolderPageTitleInTitleArea”runat=”server”>

My Application Page

</asp:Content>

image

Now it’s time to create a method to send data to the list. When you use the application page all behaviors depend on you, so without that the button will be useless. As you see in the code of the page, I put already OnClick method into button control. The method code is below:

protectedvoid SaveList(object sender, EventArgs e)

        {

        

            SPList list = SPContext.Current.Web.Lists.TryGetList(“Financial Workflow List”);

           

            SPListItem newItem = list.Items.Add();

            newItem[“InvoiceNr”]=InvoiceNumber.Text.ToString() ;

            newItem[“InvoiceDt”]=InvoiceDate.SelectedDate ;

            newItem[“InvoiceAm” ]=InvoiceAmount.Text ;

            newItem[“Supplier” ]=Supplier.Text.ToString ();

            newItem[“PurchaseOrder”]=PurchaseOrder.Text.ToString()  ;

            newItem.Update();

         

            HttpContext context = HttpContext.Current;

               if (HttpContext.Current.Request.QueryString[“IsDlg”] != null)

                {

                    context.Response.Write(“<script type=’text/javascript’>window.frameElement.commitPopup()</script>”);

                       context.Response.Flush();

                       context.Response.End();

                       }              

                }

    }

Ok, so what do we do? The first part of the code creates an instance of our list. Then we assign values of our controls to proper columns of the list. And after that, we finally call Update() method to put data on the list. In the end, we have to remove the application page from the screen. Also this last part of the code refresh content of our list.

And that’s all. I’ll try to create the next part of the series “Application pages” and present how we can place there additional functionality.

Related

Filed Under: Development, SharePoint Tagged With: SharePoint

About Tomasz Szulczewski

I've got more than 20 years of IT experience. IT is my passion and I am still increasing my skills. I work as a SharePoint, Office 365 and Azure architect.

Reader Interactions

Comments

  1. SutoCom says

    October 26, 2012 at 8:13 pm

    Reblogged this on Sutoprise Avenue, A SutoCom Source.

    Reply
  2. Raheena says

    November 12, 2012 at 7:30 am

    nice article.. waiting for you to post part 3.

    Reply
  3. Tomasz Szulczewski says

    November 12, 2012 at 9:33 am

    Thank you. I hope that It will be ready soon.

    Reply

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Primary Sidebar

Join the Newsletter

Social media

  • Facebook
  • Instagram
  • LinkedIn
  • Twitter
  • YouTube

Search this site

Sign up for Wise accounts

Signup and earn $25

payoneer
payoneer

My latest achievement

Microsoft 365 Certified: Enterprise Administrator Expert
Microsoft 365 Certified: Enterprise Administrator Expert

Tags

Azure Azure Active Directory BizSpark Blog career Certification cloud conference edge freelance Freelancer Hardware home office InfoPath Intune Knowledge licensing Microsoft Microsoft 365 News Office Office 365 Personal development Power virtual agent Private security SharePoint SharePoint designer SharePoint online Software SQL server upwork Windows Windows 365 yammer

Footer

Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Cookie Policy

Copyright © 2022 Tomasz Szulczewski