Create a simple hello world custom Application Page in SharePoint.


There are two approaches we can follow while creating an Application Page in SharePoint.

One is Inline Approach

·         Create a new default.aspx page rename it to HelloWorldAppPage.aspx

·         Put the following markup in it

<%@ Page Language=”C#” MasterPageFile=”~/_layouts/application.master” Inherits=”Microsoft.SharePoint.WebControls.LayoutsPageBase” %>

<asp:Content ID=”Main” ContentPlaceHolderID=”PlaceHolderMain” runat=”server”>

  <asp:Label Text=”Hello World” runat=”server” ></asp:Label>

</asp:Content>

·         Every application page is an content page in SharePoint. And here to have same look and feel as the other application pages we have specified the application.master as the masterpagefile.

·         Inherits attribute of the Page directive refers to LayoutsPageBase class from which the application pages inherit.

·         We have than used a content server control that would be referring to the PlaceHolderMain content place holder inside the application.master page.

·         Than we have simple added a label control that would be displaying hello world.

·         Now go to your 12 hive i.e. C:Program FilesCommon FilesMicrosoft Sharedweb server extensions12TEMPLATELAYOUTS and create a folder (MyHelloWorld) over there and put the HelloWorldAppPage.aspx over there.

·         We could have directly placed the aspx page to layouts folder but than from better organization perspective we have created a folder and kept the aspx page inside it.

·         Now the page is available to all the SharePoint sites.

http://servername:port/_layouts/MyHelloWorld/HelloWorldAppPage.aspx

Another is code behind approach.

·         The easiest way is to first create a Asp.NET Web site project.

·         Add a class library project to the solution (GCL)

·         Delete class1.cs and copy the default.aspx.cs page from asp.net web site project to the class library project.

·         Delete the default.aspx.cs from the website.

·         Add reference to System.Web and Microsoft.SharePoint.dll  in your class library project

·         Put the following code in the _Default

public partial class _Default : LayoutsPageBase

{

    protected Label Label1;

    protected void Page_Load(object sender, EventArgs e)

    {

        Label1.Text = “Hello World Code Behind”;

 

    }

}

·         Sign the assembly and put it in GAC.

·         Get the public key token.

·         In the default.aspx page replace and put the following markup to use the assembly.

<%@ Page Language=”C#” MasterPageFile=”~/_layouts/application.master”

 Inherits=”_Default,GCL, Version=1.0.0.0,Culture=neutral,PublicKeyToken=16391a8a7c882343″ %>

<asp:Content ID=”Main” ContentPlaceHolderID=”PlaceHolderMain” runat=”server”>

  <asp:Label ID=”Label1″ Text=”Hello World” runat=”server” ></asp:Label>

</asp:Content>

·         Put default.aspx to the  layouts folder or your custom folder inside it.

That’ s it !!

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

30 thoughts on “Create a simple hello world custom Application Page in SharePoint.”

  1. This is a nice post.

    Though I’m wondering how to get a button to work, because when I use a button, I also need an event handler for that button, when it’s clicked. So I am wondering how that would work.

    I did:

    protected Button Button1;
    protected override void OnLoad(EventArgs e)
    {
    Button1 = new Button();
    Button1.Text = “Click”;
    Button1.Click += new EventHandler(Button1_Click);
    }

    void Button1_Click(object sender, EventArgs e)
    {
    //code
    }

    and in my aspx page:

    I added a button with name “Button1” and tried to put a OnClick attribute, but that didn’t work, I got a “Method not found” error. When i remove that, the page is displayed, but the button only performs a postback.

    Like

  2. This is a nice post.

    I am having the same problem Johan reported. I have added a button to the page and added an event handler. The button will post the page but does not raise the event as expected.

    Is there a trick to getting control events to work?

    Like

  3. Hi Richard,

    You will not have the issue when you code it inline. That’s the solution Nishant sent me.

    But ofcourse I would like to have a solution to do it all in code behind. And i succeeded.

    Actually it’s quiet simple to do (and a stupid error too).
    Just leave the instantiation of the controls you’ve placed on your aspx page out and it will work.
    Why? The controls are already instantiated. And because you inherit from the code behind, the declaration “protected Button button1” points to the same place in memory as the button1 on your aspx form.

    So my correct code would be:

    protected Button Button1;
    protected override void OnLoad(EventArgs e)
    {
    Button1.Text = “Click”;
    Button1.Click += new EventHandler(Button1_Click);
    }

    protected void Button1_Click(object sender, EventArgs e)
    {
    //code
    }

    protected is necessary because private (standard when only void is used) wouldn’t be accessible by your aspx.

    Hope this helps.

    Like

    1. I figure it out my problem…. I needed to add AutoEventWireup=”true” on the aspx

      and wire the event as follows:

      in the code behind create method “resetPassBtn_Click”

      so the key was the AutoEventWireup=”true”

      Like

  4. Is not spam, it is only my commercial offer. Sorry if i mistake of topic!

    Buy Clomid – Best testimonials. Buy now. Satisfaction is guaranteed.
    Best price for brand and generic medications.
    From $0.60 per item. Free Airmail shipping for Clomid 100mg 90 tabs and save $135 on order!

    Like

  5. /**************************example******

    protected void Page_Load(object sender, EventArgs e)
    {
    Label1.Text = “Hello World Code Behind”;
    }
    protected void btnSubmit_onclick(object sender, EventArgs e)
    {
    Label1.Text = “Hiiii…”;
    this.txtValue.Text = “click submit”;
    }

    Testing custom application page

    http://sys-97/testdorlog/_layouts/samarendra/Test.aspx

    /**************************end******
    It’s working fine for me……

    Thanks
    -Samarendra Swain

    Like

  6. i followed the code behind – approach that time

    i am getting error like ‘Your are not authorised person to view page ‘

    Like

  7. Имеется большое количество сайтов, где без труда вы имеете возможность закачать или просмотреть ролики. Аэнтар с сожалением отключил Палантир и поплелся за Элхэ, натыкаясь на стены и не вписываясь в повороты. . Есть альтернатива – это ТВ онлайн.

    Like

  8. Hey guys,

    I am getting the error.

    Could not load the assembly ‘Version=1.0.0.0, Culture=neutral, PublicKeyToken=553dbbf1b9a1f6ba’. Make sure that it is compiled before accessing the page. at System.Web.UI.TemplateParser.GetType(String typeName, Boolean ignoreCase, Boolean throwOnError)

    please help

    Like

  9. This founded on the fact that the urethra (tube in penis employed as passage for urine and semen) can absorb certain medicines for the surrounding tissues and causes creating erection. She must extend all his support and goodwill and strive to learn everything concerning the issue. Acupuncture can correct erectile dysfunction.

    Like

  10. The injectible used are Progtaglanden (PGEI-or Prostin or Alpostradil or Caverject) papaverine hydrochloride and phentolamine (Regitine). They really should both other venues for reaching their mutual sexual satisfaction. An impotent males’ way of living must be changed for the better. There will also be a laboratory and some other tests.

    Like

  11. When oral medications fail, intravenous therapy could be accomplished as an alternative where the drug is injected directly to the penis. Other options for a man to sustain an erection are:utilizing a Vacuum Constriction Device (VCD), Intraurethal therapy or Penile Implant. Parkinson Illness is really a risk factor for potency and most of the time is over-looked.

    Like

  12. Age Most males can have strong erections until they are about 80 years old. Nevertheless, 80 percent of men who’re over the age of 75 tend to have erectile dysfunction. Know that whilst this sounds like age will be the culprit, normally older men are having erectile dysfunctions because of other medical issues they’ve developed with age (high blood pressure, heart issues, and so on.

    Like

  13. Erectile dysfunction is also known as impotence and in this difficulty erection just isn’t so difficult to do sexual intercourse and second factor males can not keep erection as long that he can finish the intercourse properly. This erection dysfunction problem effects lots of males and there sexual life. The major reason of erectile dysfunction is deficiency of testosterone simply because because of testosterone erection occurs

    Like

  14. Erectile dysfunction may cause or exacerbate psychological troubles for example poor motivation, feelings of inadequacy, frustration, denial and low self-esteem, and could ultimately result in depression. Erectile dysfunction includes multiple sexual disorders, but most frequently it’s regarded as to be the persistent inability to have an erection or to maintain it for a sufficient amount of time. Erectile dysfunction (ED), also recognized as impotence, will be the inability to achieve or sustain an erection for satisfactory sexual activity.

    Like

  15. Those looking for erectile dysfunction drugs normally try Viagra initial because it’s known to be powerful. Cialis, on the other hand, is also most sought by those looking for powerful erectile dysfunction drugs due to the fact it stays longer in the body 24 to 36 hours compared to the other two.

    Like

  16. When it is all about sexual pleasure, there’s no compromise either for a woman or for a man. Unfortunately, man suffers more than woman about sexual dysfunction given that there are numerous chances that male reproductive method and its organs to get affected due to plenty of elements. Erectile dysfunction is among the significant concerns that have hit millions of males across the globe; irrespective of the race, breed and region.

    Like

  17. Write more, thats all I have to say. Literally, it seems as though you relied on the video to make your point.
    You definitely know what youre talking about, why throw away your intelligence on just posting videos to your site when you could
    be giving us something enlightening to read?

    Like

  18. Du musst einige online-Forschung zu tun, um eine gute und echte online-Shop zu finden. Sie können auch sprechen, Familie oder Freunde, die Erfahrung in der Medizin in einem Onlineshop zu kaufen.

    Like

Please share your thoughts

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

Power Spark

Power Spark By Shrangarika

Van Carl Nguyen

Exploration of Power Platform

My Trial

It is my experience timeline.

Power⚡Thomas

Sharing my knowledge and experience about the Microsoft Power Platform.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog of Paul Andrew

Sponsored by Cloud Formations Ltd

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Dynamics 365 Ninja!

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog

Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform

Knowhere365

Specific topics by Django Lohn on the whole Microsoft365 Stack

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions

MG

Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue MVP

A Microsoft Business Applications MVP

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM

CRM TIPS BY PRM

Mail to crmtipsbyprm@gmail.com for queries and suggestions

nijos.dev

Giving back to the community what I have learned

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.

CRM Keeper

Dynamics 365 Customer Engagement, CRM, Microsoft CRM, Dynamics CRM