Skip to main content

SharePoint Form Controls


When you are writting aspx page for SharePoint 2003/2007, you can use the controls provided by SharePoint to maintain the same form style like this:

In order to use these controls, you need to add these lines in the top of your aspx page:
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" src="~/_controltemplates/InputFormSection.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" src="~/_controltemplates/InputFormControl.ascx" %>
<%@ Register TagPrefix="wssuc" TagName="ButtonSection" src="~/_controltemplates/ButtonSection.ascx" %>

Also, you need to put all these controls inside a HTML table tag:

Here is the code snippet that generates the above form:
<table border="0" width="100%" cellspacing="0" cellpadding="0" id="diidProjectPageOverview">
<wssuc:InputFormSection Title="Locale"
Description="Specify the world region that you would like the site dates, numbers and sort order to be based on."
runat="server">
<Template_InputFormControls>
<wssuc:InputFormControl LabelText="Follow web settings" LabelAssociatedControlID="ChkFollowWebRegionalSettings" runat="server">
<Template_Control>
<asp:CheckBox id="ChkFollowWebRegionalSettings" Text="Always follow web settings" runat="server" />
</Template_Control>
</wssuc:InputFormControl>
<wssuc:InputFormControl LabelText="Choose Locale" LabelAssociatedControlID="DdlwebLCID" runat="server">
<Template_Control>
<asp:DropDownList ID="DdlwebLCID" AutoPostBack="true" Runat="server">
<asp:ListItem Text="us-EN" Value="su" />
<asp:ListItem Text="ca-EN" Value="mo" />
</asp:DropDownList>
</Template_Control>
</wssuc:InputFormControl>
</Template_InputFormControls>
</wssuc:InputFormSection>
<wssuc:ButtonSection runat="server" ShowStandardCancelButton="false">
<Template_Buttons>
<asp:Button UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" Text="OK" id="BtnUpdateRegionalSettings"/>
<asp:Button UseSubmitBehavior="false" runat="server" class="ms-ButtonHeightWidth" Text="Cancel" id="BtnCancel"/>
</Template_Buttons>
</wssuc:ButtonSection>
</table>

There are several SharePoint controls used here. We will explain them one by one.
1. InputFormSection: This control defines the left part of input form section. It has two important properties:
  • Title: The first line (bold) in left input section. For example: "Locale".
  • Description: The descriptive text under the title line. For example: "Specify the world region that you would like the site dates, numbers and sort order to be based on.".
2. Template_InputFormControls: It is inside InputFormSection. It has no property to set. It wraps all the controls appearing on the right part of input form.
3. InputFormControl: It is inside Template_InputFormControls. It defines the asp.net controls inside and the label associated with the asp.net controls. You can repeat this tag to add more controls inside. It has two properties:
  • LabelText: The text above the controls. For example: "Follow web settings"
  • LabelAssociatedControlID: The control Id that the label associated with.
4. Template_Control: It is inside InputFormControl. It has no property to define. Inside this tag, you can put whatever asp.net controls and HTML code. In the above example, we put asp.net dropdown list inside.
5. ButtonSection: This section is used to define button controls.
6. Template_Buttons: This control is defined inside ButtonSection. There is no property to set. Inside this control, you can add asp.net button controls.

Comments

Anonymous said…
Good one, thanks

Popular posts from this blog

X509Certificate2: The system cannot find the file specified.

When I use the new X509Certificate2(fileName, password, X509KeyStorageFlags.DefaultKeySet) to create certificate from certificate file containing private key in my web application, I got following error message: System . Security . Cryptography . CryptographicException : The system cannot find the file specified . at System . Security . Cryptography . CryptographicException . ThrowCryptogaphicException ( Int32 hr ) at System . Security . Cryptography . X509Certificates . X509Utils . _LoadCertFromBlob ( Byte [] rawData , IntPtr password , UInt32 dwFlags , Boolean persistKeySet , SafeCertContextHandle & pCertCtx ) at System . Security . Cryptography . X509Certificates . X509Certificate . LoadCertificateFromBlob ( Byte [] rawData , Object password , X509KeyStorageFlags keyStorageFlags ) at System . Security . Cryptography . X509Certificates . X509Certificate2 .. ctor ( Byte [] rawData , String password , X509KeyStorageFlags keyStorageFlags ) In orde...

Forms authentication ReturnUrl strange behavior and fix

When working with .NET forms authentication, I have found a strange behavior: For example, we have a web site using form based authentication. There are only two pages in the site: login.aspx and default.aspx. Default.aspx is the protected page. Without login to the site, if you type directly the URL to the default.aspx page with ReturnUrl as QueryString like this: http://localhost/YourWebApp/Default.aspx?ReturnUrl=Default.aspx Instead of redirect you to the login.aspx page, you will directly get http unauthorized error (401.2). However, if you remove the ReturnUrl query string or change it to something else, you will get expected behavior: redirect to login.aspx page. It seems .NET has some special treatment to ReturnUrl parameter. In order to fix this, we need to intercept the 401 response before it sends to client and redirect user to login.aspx page. In global.asax page, we need to add this event handler:         protected void Applica...

Manage IIS 7 remotely using PowerShell and AppCmd

We can use  Windows PowerShell remoting features  to manage IIS 7 websites remotely.  Currently, remoting is supported on Windows Vista with Service Pack 1 or later, Windows 7, Windows Server 2008, and Windows Server 2008 Release 2.  Start Windows PowerShell as an administrator by right-clicking the Windows PowerShell shortcut and selecting Run As Administrator .  Enable PowerShell Remoting with Enable-PSRemoting -Force Starting a Remote Session using:  Enter-PSSession -ComputerName <COMPUTER> -Credential <USER> Now the PowerShell connected to the remote server. Any commands issued with work against the remote server. We can use the Appcmd.exe command line tool to manage remote server just as what we do locally. For example, to add an application pool: c:\windows\system32\inetsrv\appcmd add apppool /name:"Contoso" /managedPipelineMode:Integrated /managedRuntimeVersion:"v4.0" /enable32BitAppOnWin64:true To change application p...