开发者

Sharepoint 2010. Few simple questions

开发者 https://www.devze.com 2023-02-10 16:07 出处:网络
I have list definition. <ListInstance Title=\"tv2 - ListInstance3\" OnQuickLaunch=\"TRUE\" TemplateType=\"10002\"

I have list definition.

 <ListInstance Title="tv2 - ListInstance3"
            OnQuickLaunch="TRUE"
            TemplateType="10002"
            Url="Lists/tv2 - tips status"
            Description="My List Instance">

1) How to add default items to this list? What will hapens when i will deploy this list with default items to server when customer will type his own items.

2)I have simple web part.

How can i set default items to web part fields?

   public string WebPartTitle { get; set; }

3) I need one web part (codebehind) but for customer will be very easy to view this part as three d开发者_开发百科ifferent web parts (in web parts list). The difference only in initial values. For example one web part with title "Block 1" and second with "Block 2" But actully it will be same code and same web part. How to do that? I hope sharepoint can do such easy thing)

4) How to set to page default web parts?


  1. You can add items after list is created. If you create list with default items then your customer can of course create new items.

  2. make field for property:

    public string webPartTitle;

    public string WebPartTitle { get{ return webPartTitle;} set{ webPartTitle=value; } }

  3. use inheritance. Base class will contain common logic.

  4. You probably mean having page layout with some default webparts already in it. Use webpartzone for that.


Create the sharepoint webpart exactly as you would if you were coding an asp.net custom control. When i used to make webparts for sharepoint and aside from heightened security restrictions it was very straight forward.


For #1, you can do it directly in the XML:

<ListInstance Title="tv2 - ListInstance3"
            OnQuickLaunch="TRUE"
            TemplateType="10002"
            Url="Lists/tv2 - tips status"
            Description="My List Instance">
    <Data>
      <Rows>
        <Row>
          <Field Name='Title'>Default Item #1</Field>
        </Row>
        <Row>
          <Field Name='Title'>Default Item #2</Field>
        </Row>
        <Row>
          <Field Name='Title'>Default Item #3</Field>
        </Row>
      </Rows>
    </Data>
</ListInstance>
0

精彩评论

暂无评论...
验证码 换一张
取 消