create a 2010 sharepoint application that uses custom list forms

Upload: cesinco

Post on 08-Aug-2018

292 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    1/34

    1. Create a new SharePoint site based on the Blank template and name it Simple ASCX Form with a URL

    that ends with SimpleASCXForm

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    2/34

    . !pen "is#al St#dio $1$ and %reate a new SharePoint Pro&e%t based on the 'mpt( SharePoint Pro&e%t

    template and name it SimpleASCXForm

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    3/34

    ). Set the site*s URL and make s#re to deplo( it as a +arm sol#tion

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    4/34

    ,. A+ter the pro&e%t has been %reated- riht/%li%k on the pro&e%t name and %hoose Add0ew Folder

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    5/34

    . Spe%i+( the name SiteCol#mns +or the +older name

    2. Similarl( add a +older named Content3(pes

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    6/34

    4. 0e5t add the SharePoint La(o#ts 6apped +older

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    7/34

    7. Finall(- add a SharePoint 6apped +older

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    8/34

    8. Choose the C!03R!L3'6PLA3'S +older in the sele%tion list

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    9/34

    1$. Riht/%li%k on the SiteCol#mns +older and %hoose Add0ew 9tem:

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    10/34

    11. From the list o+ SharePoint items to %reate- %hoose 'mpt( 'lement and rename the de+a#lt name

    'mpt('lement1 to SiteCol#kmns

    1. ;ithin the

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    11/34

    1). From the 3ools p#ll/down men#- %hoose Create ?U9@ and #se the Cop( b#tton to %op( the

    enerated ?U9@ into the %lipboard.

    1,. Paste the %lipboard %ontents into the 9@ attrib#te +or ea%h new +ield- makin s#re to enerate a new

    ?U9@ +or ea%h b( %li%kin the 0ew ?U9@ b#tton be+ore %li%kin the Cop( b#tton.

    1. Add the 0ame and 3(pe al#es +or ea%h +ield- re+errin to the +ollowin +or #idan%e on +ield t(pes and

    an( optional or additionall( re#ired attrib#tes based on other %hoi%es made +or the +ield de+inition.

    http>msdn.mi%roso+t.%omen/#slibrar(aa8484DEo++i%e.1,.asp512. For e5ample- (o# %an %op( and paste the +ollowin %ode within the =%e

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    12/34

    Type="Te;*"/> Al*e+a*i?e Ee+:y #mp(*e+

    #)(me+/@ami: Dee)e/Ae+)pace Id()*+ial/i:.*i: %edical Telecm T+a)p+*a*i

    14. Riht/%li%k on the Content3(pes +older and %hoose Add0ew 9tem:

    17. 9n the list o+ items- %hoose Content 3(pe and rename the de+a#lt 0ame to Content3(pe G Re#est

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    13/34

    18. "is#alSt#dio $1$ will %onne%t to (o#r newl( %reated site to retriee the e5istin %ontent t(pes.

    $. Choose 9tem as the inherited +rom %ontent t(pe- then %li%k the Finish b#tton.1. 6odi+( the Content3(pe element*s 0ame attrib#te - optionall( iin a di++erent ?ro#p name and

    @es%ription b#t makin s#re to %hane the 9nherits attrib#te +rom 3RU' to FALS'- +or e5ample

    . 'a%h +iled that (o# want to make part o+ the %ontent t(pe sho#ld be added as a

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    14/34

    ). Also add the mandator( 3itle %ol#mn that has the well/known 9@ o+ H+a2,e$+/$%4$/,ab8/b72)/

    $144e2ddd,4I as well as the b#ilt/in Atta%hments %ol#mn with an 9@ o+ H24d+87+,/8de%/,7++/a)/

    8be%e8%b+,I

    ,. Lastl(- in this +ile- een tho#h we hae not %reated the %#stom +orm (et- we %an spe%i+( that the %ontent

    t(pe will #se a di++erent +orm +rom the de+a#lt ListForm. 9+ we intend to ie o#r %#stom +orm the 9@Re#estForm and i+ we intend to #se the same +orm +or 0ew- @ispla(- and 'dit p#rposes- the %ode that

    sho#ld be entered a+ter the %losin

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    15/34

    7. 9n the List @e+inition Settins dialo- %hane the displa( name o+ the list de+inition to List G

    @epartments- set the t(pe to C#stom List- and keep the list instan%e %he%kbo5 %he%ked.

    8. A series o+ +iles and +olders will et enerated b#t the 'lements.5ml +ile +or the list de+inition will be

    opened in the editor. 6ake the %hanes as s#ested b#t make s#re that +or ea%h new list de+inition- (o#

    %hane the List3emplate element*s 3(pe attrib#te to a #ni#e al#e +or the pro&e%t. 9+ the list is not

    intended to be #sed +re#entl( and is meant onl( +or look#ps- we %an %hoose to not displa( the list name

    on the J#i%kLa#n%h. For e5ample- the %hanes (o# make miht look like>

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    16/34

    )$. For easier identi+i%ation- rename the +olders and +iles %reated +or the list

    i.e. rename the +older List9nstan%e1 to List instan%e G @epartments- and the +iles 'lements.5ml to

    'lements@[email protected] and 'lements9nstan%[email protected] respe%tiel(.

    )1. 'dit the +ile 'lements9nstan%[email protected] %hanin 3emplate3(pe to mat%h the 3(pe de+ined

    in the list de+inition and Url to mat%h the List attrib#te in the de+inition o+ the @epartment Site Col#mn

    ). ;ithin the

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    17/34

    ale)

    )). !pen the S%hema.5ml +ile +or the list de+inition

    ),. Chane the

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    18/34

    )4. Ko# %an %on+irm this b( naiatin to the Lists iew and then openin the new @epartments list

    )7. 3o add the %#stomied +orm additional steps m#st be taken.

    )8. Start b( %reatin the list that will #se the preio#sl( de+ined %ontent t(pe and (et/to/be/desined %#stom

    +orm. Add to the Lists +older a new List @e+inition Dnot List @e+inition From Content 3(pe and name it

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    19/34

    List G Re#ests

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    20/34

    ,$. 6odi+( the List @e+inition Settins dialo appropriatel(- then %li%k Finish

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    21/34

    ,1. Rename the +iles and +olders similarl( to the names #sed when de+inin the @epartments list

    ,. 9n the newl( renamed 'lements@e+initionListRe#ests.5ml- modi+( the List3emplate ta*s attrib#tes so

    that the 3(pe is #ni#e and addin the @isallowContent3(pes with a al#e o+ False- i.e.

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    22/34

    ;ml)B0)="%ic+)* .a+ei*" Ti*le="&e'(e)*)" Flde+#+ea*i="FAE" Di+ec*i="G&e)(+ce)BDi+ec*iH" ,+l="i)*)/&e'(e)*)" a)eType="" ;ml)=".**pB//)c.ema)Cmic+)*Ccm/).a+epi*/ " Eale#*e*Type)="T&,E" >

    ,. Remoe Dor %omment o#t the Content3(peRe+ elements %#rrentl( present within the *day E;pe)e #api*al E;pe)e Al*e+a*i?e Ee+:y #mp(*e+ #)(me+/@ami: Dee)e/Ae+)pace Id()*+ial/i:.*i: %edical Telecm T+a)p+*a*i

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    23/34

    ,4. 0ear the bottom o+ the S%hema.5ml +ile- lo%ate the

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    24/34

    then in the s#b+older TEMP!TE\C"#T$"TEMP!TESopen the +ile named @e+a#lt3emplates.as%5 in a

    te5t editor- then %op( the Renderin3emplate that has the idEListForm into (o#r %lipboard.

    ,. Paste the %ontents o+ the %lipboard into the bottom o+ the Re#estRenderin3emplate.as%5 +ile that (o#

    %reated

    . 6ost importantl(- (o# m#st repla%e the al#e o+ the renderin template*s id attrib#te %#rrentl( set to

    ListForm with Re#estForm or else all lists will render #sin (o#r %#stom +orm.

    2. 0e5t- edit the %ontents o+ that +ile to remoe the re+eren%e to the ListField9terator- whi%h is howSharePoint normall( renders +orm +ields Db( sta%kin one +ield on top o+ the other. 9n its pla%e- we will

    add a ta re+errin to the +orm %#stom +orm. Also- delete%omment o#t the re+eren%e to the

    Atta%hmentRows template G we will be addin o#r own renderin o+ atta%hment re+eren%es.

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    25/34

    4. Add &J#er( libraries and CSS st(lesheets Dwith imaes. Riht/%li%k on the a%o&ts\Sim'le!SC(Form

    pro&e%t +older and %hoose Add0ew Folder and name it S%ripts. Repeat +or a +older named St(les.

    7. 9nto the S%ript +older- %op( the +iles er(/1.7.).min.&s and er(/#i/1.8..redmond.min.&s Dor some

    other &J#er( minimied ersion andor theme instead o+ the Redmond theme. See atta%hed reso#r%es.

    8. Ass#min (o# are #sin the Redmond &J#er( U9 theme- into the St(les +older %op( the +iles er(/#i/

    1.8..redmond.min.%ss and 0P@St(les.%ss as well as the 9maes +older. See atta%hed reso#r%es.

    2$. 9n the Sol#tion '5plorer pane- %li%k on the se%ond i%on Dto Show All Files.

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    26/34

    21. Sele%t ea%h o+ the +iles+older that (o# %opied b( Ctrl/Cli%k to keep them sele%ted- then riht/%li%k on an(

    one and %hoose 9n%l#de 9n Pro&e%t whi%h will %hane their i%ons +rom plain white to their de+a#lt.

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    27/34

    2. Riht/%li%k on the pro&e%t name and %hoose Add0ew 9tem: and sele%t the User Control- b#t rename

    it to FormRe#est.as%5 +rom its de+a#lt UserControl1.as%5

    2). 3his will a#tomati%all( %reate a new hierar%h( in the C!03R!L3'6PLA3'S +older startin with the name

    o+ the pro&e%t.

    2,. @o#ble/%li%k on the FormRe#est.as%5 item to open it in the editor.

    2. Below the st#b %ode that was %reated add the re+eren%es to the S%ript and St(le +iles that we %opied

    earlier- i.e.

    22. Below this- add the NaaS%ipt %ode in%l#din the &J#er( tab %ode- and an( hidin that o#ht to o%%#r

    based on possible stat#s o+ the item D0ew- @ispla(- 'dit or i+ isibilit( o+ some +ields depends on the

    al#es o+ others.

    GVdc(me*WC+eadyV(c*iVW { GV"Q*a)"WC*a)VWH // ide all *.e *a) i 0e a+e i *.e e0 +m i V0id0Clca*iCpa*.ameCide;9VSNe0F+mCa)p;SW = -1W { //GVSQ*a)SWC*a)V"+em?e"O "Q.eade+Ta&ead9ly"WH GVSQ*a)SWC*a)V"+em?e"O "Q+e'(e)*De*ail)Ta"WH GVSQ*a)SWC*a)V"+em?e"O "Qa**ac.me*)Ta"WH el)e{ //F+ Di)play ad Edi* +m)O )me c.a:e) a+e cmm

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    28/34

    //GVSQ*a)SWC*a)V"+em?e"O "Q.eade+Ta"WH //me c.a:e) a+e )peciic * Edi* +m ly i V0id0Clca*iCpa*.ameCide;9VSEdi*F+mCa)p;SW = -1W { //(* *.e *0 +adi (**) e +0 ?a+)pa&dE;pe)e = GV")paCm)-&adiTe;**i*le=SE;pe)eS" WH ?a+*dE;pe)e = )pa&dE;pe)eCpa+e*VWH ?a+*+E;pe)e = *dE;pe)eCpa+e*VWH ?a+.*mlE;pe)e = *dE;pe)eC.*mlVWH ?a+)pa&d#api*al = GV")paCm)-&adiTe;**i*le=S#api*alS" WH *+E;pe)eC+em?eVWH

    )pa&d#api*alCa*e+V.*mlE;pe)eWH

    //A++a:e c.ec;e) i* 3 cl(m) i)*ead .a+ei* dea(l* 1 ?a+%A#9,%N = 3H ?a+a++T% = H ?a+a++DelT& = H ?a+*+a)*Pep*&0 = (llH ?a+)pa#.Fi+)* = GV")paCm)-&adiTe;**i*le=SAl*e+a*i?e Ee+:yS"WH //Fid *.e i+)*V+ ayW c.ec; )pa ?a+*+#.) = GV)pa#.Fi+)*WCpa+e*VWCpa+e*VWCpa+e*VWCc.ild+eVWH //Fid *.a* c.ec;S)T9DX * :e* a* *.e T& )ili:) GV*+#.)WCeac.V(c*iVide;W { //I*e+a*e *.+(:. *.e +0)O eepi: e?e+y 3+d Vi *.i)e;ampleWO ad m?i: *.e+ +0 c*e*) i* cell) iVide; L %A#9,%N > W { iVide; L %A#9,%N == 1W { *+a)*Pep*&0 = GV*+#.)ide; - 1WH

    a++T%Cp().VGV*.i)WC.*mlVWWH a++DelT&Cp().VGV*.i)WWH el)e{ +V?a+i = H i < a++T%Cle:*.H iYYW { GV*+#.)ide; - %A#9,%NWCappedVa++T%iWH a++T%Cle:*. = H W //Apped ay +emaii: c.ec;e) *.a* did * cmple*e a +0 iVa++T%Cle:*. > W { +V?a+i = H i < a++T%Cle:*.H iYYW { GV*+a)*Pep*&0WCappedVa++T%iWH

    //Dele*e +0) l:e+ +e'(i+ed +V?a+i = H i < a++DelT&Cle:*.H iYYW { a++DelT&iC+em?eVWH

    //&e:a+dle)) 0.a* mde 0e a+e iO al0ay) )e* *.e 9+i:ia*+ ield * di)aled mde ad 0e .a?e* d //addi*ial *+ice+y * :e* a+(d *.e ac* *.a* a di)aled *e;* ield 0ill * )ed i*) c.a:e)* *.e )e+?e+ GV"ip(**i*le=S9+i:ia*+S" WCa**+V"+eadly"O "+eadly"WCc()iV.dlFc()9+i:ia*+WH GV"ip(**i*le=S9+i:ia*+S" WCc))V"ac:+(d-cl+"O "QE6F1FF"WCc))V"+de+-0id*."O WH W

    (c*i.dlFc()9+i:ia*+VW {

    ?a+; = GV"di?Cm)-ip(*()e+ieldidZ=S#$%&e'(e)*e+S" WH ?a+id&e'(e)*e+ = GV;WCa**+V"id"WH dc(me*C:e*Eleme*yIdVid&e'(e)*e+WCc()VWH

    24. Below this- add the M36L %ode that will displa( the +ields on the +orm.

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    29/34

    a)ic I &e'(e)* De*ail) A**ac.me*)

    &e'(e)* a)ic I+ma*i

    De*ail)

    Fiacial) De)c+ip*i

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    30/34

    (pp+*i: dc(me*a*i A**ac.me*)

    ?a+elm =

    dc(me*C:e*Eleme*yIdV"idA**ac.me*)Tale"WH ?a+elmA**ac.me*&0 =

    dc(me*C:e*Eleme*yIdV"idA**ac.me*)&0"W iVVelm == (ll[[ elmC+0)Cle:*. == W

    VelmA**ac.me*&0 = (llWW elmA**ac.me*&0C)*yleCdi)play = SeSH

    27. 3he %ode aboe renders the Atta%hments +ield on the Atta%hments tab rather than a+ter all other +ields

    as is #s#al +or de+a#lt SharePoint +orms.

    28. Ko# %an now do another deplo(ment o+ the pro&e%t- whi%h sho#ld %reate another Db#t empt( list +or

    re#ests. Creatin a new list item +or that list sho#ld brin #p the new %#stom +orm.

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    31/34

    4$. Creatin a new Re#est item onl( shows the 3itle and Re#ester +ields as editable Din the Basi% 9n+o tab

    41. A+ter sain- it %an be opened in 'dit mode to +ill in the remainin +ields

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    32/34

    4. A+ter sain those %hanes- in%l#din atta%hin +iles- we %an see all ) tabs with in+ormation

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    33/34

    4). 3he list o+ SharePoint $1$ b#ilt/in +ield names are listed at> http>msdn.mi%roso+t.%omen/

    #slibrar(mi%roso+t.sharepoint.spb#iltin+ieldidO+ieldsDEo++i%e.1,.asp5

    4,. 3he list o+ SharePoint $$4 b#ilt/in +ield names A0@ their 9@sis listed here>

    http>blos.msdn.%ombmi%haelO(eaerar%hie$$711$)re+eren%e/list/+or/internal/+ield/

    names.asp5

    4. Alternatiel(- (o# %an enerate (o#r own listin o+ b#ilt/in +ields #sin the +ollowin Powershell s%ript

    Add-PsSnapin Microsoft.SharePoint.PowerShell

    ## SharePoint DLL

    [void][System.Reflection.Assemly]!!Load"ithPartialame$%Microsoft.SharePoint%&

    # Description# '(tp(t all availale )ol(mn *ield +,Ds to All)ol(mn*ields.csv

    # Settins Start

    set-variale -option constant -name (rl -val(e %http!//cvm-

    home01!2333/sites/e4perimental/% # Site collection

    set-variale -option constant -name o(t -val(e %D!All)ol(mn*ields.csv% # '(tp(t file

    # Settins 5nd

    6site 7 new-o8ect Microsoft.SharePoint.SPSite$6(rl&

    6we 7 6site.rootwe.*ields

    echo %+eneratin *ile...%

    *or5ach $6id in 6we&

    9

    :%: ; 6id.%: ; 6id.d ; =

    :%>%: ; 6id.nternalame ; =

    :%>%: ; 6id.Staticame ; =:%>%: ; 6id.Ma4Lenth ; =

    :%>%: ; 6id.Description ; =

    :%>%: ; 6id.+ro(p ; =

    :%>%: ; 6id.

  • 8/22/2019 Create a 2010 SharePoint Application That Uses Custom List Forms

    34/34

    42. Use+#l links>

    http>msdn.mi%roso+t.%omen/#slibrar(mi%roso+t.sharepoint.spb#iltin+ieldidO+ieldsDEo++i%e.1,.asp5

    http>msdn.mi%roso+t.%omen/#slibrar(aa8484DEo++i%e.1,.asp5

    http>msdn.mi%roso+t.%omen/#slibrar(ms,28,4DEo++i%e.1,.asp5

    http>msdn.mi%roso+t.%omen/#slibrar(ms,)7))7DEo++i%e.1,.asp5

    http>msdn.mi%roso+t.%omen/#slibrar(ms,42$2DEo++i%e.1,.asp5

    http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbuiltinfieldid_fields(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/aa979575(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/ms462947(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/ms438338(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/ms476062(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spbuiltinfieldid_fields(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/aa979575(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/ms462947(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/ms438338(v=office.14).aspxhttp://msdn.microsoft.com/en-us/library/ms476062(v=office.14).aspx