Tuesday, September 29, 2009

Using sharepoint webcontrols for desinging forms

I prefer using share point web controls for designing share point custom aspx form as they provide extended properties and also provide look n feel similar to out of box look n feel.

Following is an useful msdn link for getting help related to controls
http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.aspx


They are easy to brand with overall theme and master pages. following are list of few important controls

  1. Text Box -- SharePoint:InputFormTextBox
  2. Drop down -- SharePoint:DVDropDownList
  3. People Editor -- SharePoint:PeopleEditor
  4. Date Time -- SharePoint:DateTimeControl (for details on validation)
  5. Labels -- Sharepoint:EncodedLiteral
Also there are few important webcontrol that can be utilized for creating sections and aligning controls

  1. /_controltemplates/InputFormSection.ascx for Defining section
  2. /_controltemplates/InputFormControl.ascx for defining control
following is a sample ascx for above
----------------------------------------------------------------------


<%@ Assembly Name="Sample, Version=1.0.0.0, Culture=neutral, PublicKeyToken=68802d514f1e9922"
%>
<%@ Control Language="C#" AutoEventWireup="true" Inherits="SampleNamespace.Sample"%>
<%@ Register TagPrefix="SharePoint" Namespace="Microsoft.SharePoint.WebControls"
Assembly="Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c" %>
<%@ Register TagPrefix="wssuc" TagName="InputFormSection" Src="/_controltemplates/InputFormSection.ascx"
%>
<%@ Register TagPrefix="wssuc" TagName="InputFormControl" Src="/_controltemplates/InputFormControl.ascx"
%>


<wssuc:InputFormSection Title="City" Description="Please select City." runat="server">
<template_inputformcontrols>
<wssuc:InputFormControl runat="server" LabelText="Country:" >
<Template_Control>
<SharePoint:DVDropDownList ID="cmbCoutnry" runat="server" AutoPostBack="true" />
</Template_Control>
</wssuc:InputFormControl>
<wssuc:InputFormControl runat="server" LabelText="City:">
<Template_Control>
<SharePoint:DVDropDownList ID="cmbCity" runat="server" />
</Template_Control>
</wssuc:InputFormControl>
</template_inputformcontrols>
</wssuc:InputFormSection>

<wssuc:InputFormSection Title="Dates" Description="Please select Dates." runat="server">
<template_inputformcontrols>
<wssuc:InputFormControl runat="server" LabelText="Start Date:">
<Template_Control>
<SharePoint:DateTimeControl ID="dtStartDate" runat="server" />
</Template_Control>
</wssuc:InputFormControl>
<wssuc:InputFormControl runat="server" LabelText="End Date:">
<Template_Control>
<SharePoint:DateTimeControl ID="dtEndDate" runat="server" />
</Template_Control>
</wssuc:InputFormControl>
</template_inputformcontrols>
</wssuc:InputFormSection>

No comments:

Post a Comment