Pregunta

I am using a input form text box here is the tag

</asp:Label><SharePoint:InputFormTextBox
runat="server" ID="respRichTextBox" ValidationGroup="CreateCase" Rows="10" RichText="true"
TextMode="MultiLine" RichTextMode="FullHtml" AllowHyperlink="true">

I want to save the data entered in the InputFormTextBox(eg the text,images,links) into a sharepoint list field which is multiline type..

Thanks Appreciate your help!

¿Fue útil?

Solución

create a multiple lines of text column in SharePoint list,specify the type of text to allow Enhanced rich text (Rich text with pictures, tables, and hyperlinks).

Then you can use the code below to save the content in InputFormTextBox into the SharePoint list field:

<SharePoint:InputFormTextBox runat="server" ID="inRichTextBox" Rows="10" RichText="true" TextMode="MultiLine" RichTextMode="FullHtml" AllowHyperlink="true" ></SharePoint:InputFormTextBox>

<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />

2.The C# code:

protected void Button1_Click(object sender, EventArgs e)
        {
              SPSite site = SPContext.Current.Site;

                SPWeb web = site.RootWeb;

                    web.AllowUnsafeUpdates = true;
                    SPList list = web.Lists["list"];

                    SPListItem item = list.GetItemById(1);

                    item["InPutFormField"] = inRichTextBox.Text;

                    item.Update();

                    web.AllowUnsafeUpdates = false;




        }

Otros consejos

I never use that control. I use Custom List Form to create custom form for create, or edit an item in a list.

On the SharePoint Designer Insert menu, point to SharePoint Controls, and then click Custom List Form. This is a tutorial to use that control in SharePoint designer.

If you want to use more advance approach for your control, you can use visual webpart for that purpose. In visual web-part you can use standard asp.net control. Here a sample for creating visual webpart

If you are in ApplicationPage you can write some code to get value of your InputFromTextbox value and save it in list you want, but if you are in publishing pagelayouts you can use another control, here is an example:

<PublishingWebControls:RichHtmlField id="Content" FieldName="PublishingPageContent" runat="server"/>

in RichHtmlField control the FieldName attribute represents the multiline field in the Pages library named PublishingPageContent

Licenciado bajo: CC-BY-SA con atribución
scroll top