john pfeiffer
  • Home
  • Categories
  • Tags
  • Archives

c sharp 2008 Express WSS 3 WebPart Code Example

Visual C# 2008 Express WSS 3 Web Part Code Example

(Don't forget to Project -> Add Reference -> System.Web (.net 2 framework .dll))

using System; using System.Web; using System.Web.UI;

using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts;

namespace ClassLibrary1 { public class Class1 : WebPart { protected override void RenderContents(HtmlTextWriter writer) { writer.Write("Hello World from SharePoint"); } } }


using System; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts;

namespace ButtonPressWebpart { //class that inherits webpart features public class ButtonPressWebpart : WebPart { //define instances of objects (textbox, button, label) TextBox tb = new TextBox(); Button btn = new Button(); Label lbl = new Label();

    //function that customizes default object properties
    protected override void CreateChildControls()
    {
        btn.Text = "Click Me";
        btn.Click += new EventHandler(btn_Click);

        this.Controls.Add(tb);
        this.Controls.Add(btn);
        this.Controls.Add(lbl);
    }

    //define our custom action when clicked
    void btn_Click(object sender, EventArgs e)
    {
        lbl.Text = tb.Text;
    }

    //"render"
    protected override void Render(System.Web.UI.HtmlTextWriter writer)
    {
        EnsureChildControls();
        RenderChildren(writer);
    }
}

}


  • « vista command line connect to a wireless network
  • windows change application that opens extension »

Published

Feb 6, 2010

Category

research

~128 words

Tags

  • 2008 2
  • 3 16
  • c 95
  • code 7
  • example 36
  • express 4
  • research 199
  • sharp 4
  • webpart 4
  • wss 10