Sunday, January 20, 2008

Huntington Beach web design and development california in ASP.NET

Huntington Beach, california web design and development in ASP.NET

1. User Control
A. Like include files.
B. Reusable chunks of code.
C. End with .ascx
D. Drag onto any page
E. Change the control…all the pages change.
F. Change the location of the page…ouch..change the scr in the directive.
2. Custom Control
A. Appear in toolbox…more complex…it’s a DLL
B. Not this semester
3. Add New Web User Control
A. Design then drag onto other pages.
4. You can create properties for a control
A. And set those properties in the code of the page you drag it on.
5. To access properties and events of user control
A. You have to add the declare at the top of the form.
B. Protected WithEvents ddlList As System.Web.UI.WebControls.DropDownList
1. (this is automatically done for standard controls, you have to type it for your user controls.)
6. Placing a Control on a page creates a directive at the top of the HTML page
B. Delete the control does not remove this
7. At the location of the code a tag referring to that control
1. note how uc1 refers to the tagprefix in the Register
2. If you add another instance it refers to the same register
B. KEY Point. If you have control properties….they become tag attributes of the tag in HTML view…important.
8. The UC contains and hides it’s composite (child) controls
A. User does NOT have access to the controls inside the UC
1. The properties of internal controls on the UC are invisible outside the control
B. You must “Expose” or Map any properties on the internal controls back to the outside so you can access them….Easy
9. Exposing Properties on your control: Easy
A. Create a Public property the same name as built in property of a server control on the user control
B. Set the value of the property of the server control to the value of the public property you exposed.
10. Four steps to Exposing Custom events with User Controls
A. 1st in the User Control; Declare (expose) the event
1. Public Event MySelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
2. Use the same arguments as all events…
B. 2nd in the User Control find an existing event and add the following code…
1. RaiseEvent MySelectedIndexChanged(sender, e)
a) This will trigger your custom event from inside your control
C. 3rd Delcare WithEvents on the Form where the user control is added:
1. Protected WithEvents ddlCategories As DataDropDownList
D. 4th Find the control on the drop downlist of controls and code for the event you exposed when designing the user control