public class insertdatademo : System.Web.UI.WebControls.WebParts.WebPart
{
public FileUpload file;
}
public insertdatademo()
{
file=new FileUpload();
}
protected override void CreateChildControls()
{
file=new FileUpload();
file.DataBind();
this.Controls.Add(file);
oButtonSubmit.Click += new EventHandler(oButtonSubmit_Click);
}
void oButtonSubmit_Click(object sender, EventArgs e)
{
if(file.HasFile==true)
{
SPAttachmentCollection attach = myListItem.Attachments;
String fileName = file.PostedFile.FileName;
byte[] textfile = file.FileBytes;
attach.Add(fileName, textfile);
}
}
protected override void Render(HtmlTextWriter writer)
{
writer.Write("<table class='ms-formtoolbar' cellpadding='2' cellspacing='0' border='0' width='100%'><tr><td width='99%' class='ms-toolbar' nowrap><IMG SRC='/_layouts/images/blank.gif' width='1' height='18' alt=''></td><td class='ms-toolbar' nowrap='true'><TABLE cellpadding='0' cellspacing='0' width='100%'><TR><TD align='right' width='100%' nowrap>");
file.RenderControl(writer);
writer.Write("</TD></TR></TABLE></td></tr></table>");
}
You might also like:
- How to Create a SharePoint Server 2007 Custom Master Page and Page Layouts for a Web Content Management Site Office 2007
- SharePoint 2007 (MOSS/WSS) – Creating an ItemUpdating Event Handler as a feature and Packaging it in .wsp
- Creating custom list event receivers in MOSS 2007
- Insert Data Into Sharepoint List Using C# Code
- create a custom content type in MOSS 2007
No comments:
Post a Comment