Lennybacon.com■ Daniel Fisher | CTO & Software Architect ■
MCP, MCTS, MCPD…[email protected]
■ Mit-Gründer und Geschäftsführer von devcoach.comwww.devcoach.com
■ Mit-Gründer und Vorstand dergemeinnützigen www.just community.de e.V.
■ Veranstalter des größten Entwickler & IT-Pro Community Events in Deutschland: www.nrwconf.de
■ Mit-Gründer und Leiter derINETA Usergroup Düsseldorf
www.NetUG-NiederRhein.de
■ Mitglied im Microsoft Community Leader & Insider Program (CLIP)
■ Connected Systems Advisory BoardExpertengruppe für WCF, WF & BizTalk
■
devcoach.com■ Leistungen
■ Architektur-BeratungStrukturierter und effizienter zu einer wartbaren Anwendung.
■ Software-EntwicklungTeam-out-of-the-box (Near-shoring)Objektmodelle und DatenzugriffKommunikations-InfrastrukturenIdentitäts- und BerechtigungsmodelleWeb 2.0 und Rich Internet Applikation
■ Coaching & TrainingTechnologien schneller verstehen und richtig einsetzen.
■ Technologien
■ Microsoft Windows & .NET FrameworkASP.NET, WCF, WF, WPF, Silverlight & Geneva
■ Kunden
■ Versicherung, Finanzindustrie, Mittelstand, Handel, Kommunikation, Softwarehersteller u.v.a.Bundesamt für Sicherheit in der Informationstechnologie, Microsoft, Dresdner Bank…
Project Experience
Technology Know-how
devcoach®
Agenda
• Web Controls
• What‘s MVC anyway?
• Recap 2006
• Controls for the Microsoft Web Platform
• Summary
7
Is all about Maintainablility!
■ The controls concept achieves reusability for
■ Html mark-up
■ Server-side code
■ Client-side scripts
■ Compiled code that can be reused in any ASP.NET web application.
Concepts
• Nice URLs & Routing
• Process over „just add a Form“
• Loads of naming conventions
• Code, Code, Code
• As strongly typed as possible!
• Once build, forever used…
Concepts cont.
• No Code-Behind for ASPXs
• No Postbacks
• No Viewstate
• And last but not least „No controls out of Redmond“!
18
Processing
■ Child control creation
■ CreateChildControls()■ All display logic
■ OnPreRender()■ Rendering
■ Custom: Render()
■ Composite: Nothing to do?
First Aid
■ Response.Redirect(http://example.org);
■ Server.Transfer(http://example.org);
■ <a href=“…“>link</a>
■ Server side only events
■ AJAX
23
Postback - Lifecycle of a control
Instantiate : Constructor
Initialize : OnInit method and Init Event
Begin Tracking View State : TrackViewState
Load View State : LoadViewState method
Load Postback Data : IPostBackDataHandler.LoadPostdata method
Load: OnLoad method and Load event
Raise Changed Events : IPostBackDataHandler.RaisePostDataChangedEvent method
Raise Postback Event : IPostBackEventHandler.RaisePostBackEvent method
PreRender : OnPreRender method and PreRender event
Save View State : SaveViewState method
Render : Render method
Unload : OnUnload method and Unload event
Dispose : Dispose Method
24
ViewState
■ ViewState is used to track and restore the state values of controls that would otherwise be lost
■ Base64 encoded - not easily readable, but not encrypted!
■ What to store
■ Integers
■ Strings
■ Floats
■ Decimals
■ Arrays of the data types stated above
Viewstate in code
[Bindable(false)][Category("Appearance")][DefaultValue("This is the default text.")][Description("The text of the custom control.")]public virtual string Text{ get { var o = ViewState["Text"]; return o!=null ? (string) o : "This is the default text."; } set { ViewState["Text"] = value; }}
First Aid
■ Query Request.Form and Request.QueryString
■ Use local fields■ most times they work fine!
Binding in code
public overrride OnInit( object sender, EventArgs e){ List<Person> persons = Repository<Person>.GetAll(); myControl.DataSource = persons; myControl.DataBind()}
Resources in code
[assembly: WebResource("devcoach.Web.UI.Controls.Busy.gif", "image/gif")]
imageUrl = Page.ClientScript.GetWebResourceUrl(
GetType(),
"devcoach.Web.UI.Controls.Busy.gif");
Top Related