SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 282 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

Web;
using System.Web.UI;
using System.Collections.Specialized;
using System.ComponentModel;
namespace ControlsBook2Lib.Ch05
{
[ToolboxData("<{0}:textbox runat=server>"),
DefaultProperty("Text")]
public class TextBox : Control, IPostBackDataHandler
{
public string Text
{
CHAPTER 5 ?–  SERVER CONTROL EVEN TS 193
get
{
object text = ViewState["Text"];
if (text == null)
return string.Empty;
else
return (string)text;
}
set
{
ViewState["Text"] = value;
}
}
public bool LoadPostData(string postDataKey,
NameValueCollection postCollection)
{
string postedValue = postCollection[postDataKey];
if (!Text.Equals(postedValue))
{
Text = postedValue;
return true;
}
else
return false;
}
public void RaisePostDataChangedEvent()
{
OnTextChanged(EventArgs.Empty);
}
protected virtual void OnTextChanged(EventArgs e)
{
if (TextChanged != null)
TextChanged(this, e);
}
public event EventHandler TextChanged;
protected override void Render(HtmlTextWriter writer)
{
base.Render(writer);
Page.VerifyRenderingInServerForm(this);
// write out the tag
writer.Write("writer.Write(this.UniqueID);
writer.Write("\" value=\"" + this.Text + "\" />");
194 CHAPTER 5 ?–  SE RVER CONTROL EVENTS
}
}
}
Using the TextBox Control on a Web Form
The TextBox web form shown in the Design view in Figure 5-4 hosts the newly minted TextBox
control with its TextChanged event capabilities.


Pages:
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294
hotel jelenia góra Russian bride Free English grammar and study guid powiekszenia wielkoformatowe counter strike 1.6