Click here to Skip to main content
15,885,244 members
Articles / Programming Languages / C#

WebParticles: Developing and Using Web User Controls as WebParts in Microsoft Office SharePoint Server 2007

Rate me:
Please Sign up or sign in to vote.
4.90/5 (61 votes)
27 Mar 200714 min read 509.7K   1.1K   165  
Using Web User Controls in SharePoint WebParts
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace SmartParticles
{
    public partial class WebParticleControl : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            btnReset.Click +=new EventHandler(btnReset_Click);
            btnSubmit.Click +=new EventHandler(btnSubmit_Click);
        }
        protected void btnSubmit_Click(object sender, EventArgs e)
        {

            string _response    =   "Hello {0} {1} from {2}, {3}! Please reset the form!";
            string szState = ddlState.SelectedValue;

            lblResults.Text = string.Format(_response, txtFirstName, txtLastName, txtCity, szState);

        }

        protected void btnReset_Click(object sender, EventArgs e)
        {
            txtCity.Text = "";
            txtFirstName.Text = "";
            txtLastName.Text = "";
            ddlState.SelectedIndex = 0;
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Architect Dell
United States United States
I am a Big Data Architect working with MPP Database Systems and Hadoop.

Comments and Discussions