designing developing web based solutions in asp net n.
Skip this Video
Loading SlideShow in 5 Seconds..
Designing & Developing Web-Based Solutions in ASP.NET PowerPoint Presentation
Download Presentation
Designing & Developing Web-Based Solutions in ASP.NET

Loading in 2 Seconds...

  share
play fullscreen
1 / 11
Download Presentation

Designing & Developing Web-Based Solutions in ASP.NET - PowerPoint PPT Presentation

imelda-matthews
117 Views
Download Presentation

Designing & Developing Web-Based Solutions in ASP.NET

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. Designing & Developing Web-Based Solutions in ASP.NET Week 5 Custom Server Controls

  2. Today’s Agenda • Lecture: • Custom Server Control • Rendering • Adapters • Templates • Lab: • Rendering html Designing & Developing Web-Based Solutions in ASP.NET

  3. Custom Controls • Use and register same as User Controls • Derive from • Control • WebControl • or existing control Designing & Developing Web-Based Solutions in ASP.NET

  4. Render Methods to Override Best used from Control Best used with WebControl Designing & Developing Web-Based Solutions in ASP.NET

  5. Control Derived – Rendering • override void Render(HtmlTextWriteroutp) • { outp.AddAttribute(<name>,<data>) outp.AddStyleAttribute(<name>,<data>) // special outp.RenderBeginTag(HtmlTextWriterTage.Div) outp.Write(“inner elements”); outp.RenderEndTag(); • } Designing & Developing Web-Based Solutions in ASP.NET

  6. WebControl Derived Rendering Remember to: Call Base Class • Specify begin tag in constructor • Only need to override these: • RenderContents() • AddAttributesToRender() • Auto supports styles in Vis Studio property page Designing & Developing Web-Based Solutions in ASP.NET

  7. Adaptive Rendering • A class that overrides rendering on other controls. • Derive from: • ControlAdapter • or • WebControlAdapter • Set your class as the adapter to another control in the .browser file. Designing & Developing Web-Based Solutions in ASP.NET

  8. CustomControls - State • Store Variables in ViewState • Variables users of your control can access • Store needed Private data in control state • Must register to use: • Page.RegisterRequiresControlState(this); • Browser cannot turn off • Data stored in key/name pairs (not like other state) Designing & Developing Web-Based Solutions in ASP.NET

  9. CC - IPostBackDataHandler • Participate in all postbacks • Implement Interface • LoadPostData() • View updates • Update self • RaisePostDataChangedEvent() • All controls initialized on page • Can now raise custom events e.g., OnTextChanged • public event EventHandlerOnTextChanged; • Users of this control can subscribe to this event • Also several special case MUST HAVE attributes Designing & Developing Web-Based Solutions in ASP.NET

  10. Custom Controls - Ideas • Calendar Mods • Scheduler like Outlook • Composites • Address Control • Switch between State, Prov., … based on country • Brainstorm !!! Designing & Developing Web-Based Solutions in ASP.NET

  11. Lab – Rotatable Label (standard Horizontal) Text (Vertical) T E X T (-45 degrees) T E X T Designing & Developing Web-Based Solutions in ASP.NET