alert($get("MyControl").id);
Thoughts, Tips and Tricks on what I'm currently do for a living. Currently most of my spare time is spent on contributing to Akka.NET.
Wednesday, January 31, 2007
Find a control in javascript (Ajax ASP.Net)
To find a control with id "MyControl" us the function $get.
Example:
Show and Hide a ModalPopupExtender from javascript
To show a modal popup handled by a ModalPopupExtender from javascript you need to set the BehaviorID property:
<ajaxToolkit:ModalPopupExtender... BehaviorID="MyModalPopupExtender" ... />The script for showing and hiding the popup:
<script language="javascript"> function hidePopup() { $find('MyModalPopupExtender').show(); } function hidePopup() { $find('MyModalPopupExtender').hide(); } </script>
Tuesday, January 30, 2007
Asp.Net ViewState
A good article explaining ViewState in Asp.Net.
http://weblogs.asp.net/infinitiesloop/archive/2006/08/03/Truly-Understanding-Viewstate.aspx
Some of the interesting titbits:
- When a control is tracking ViewState, items changed in the ViewState will be marked dirty. Only dirty items in the ViewState StateBag will be serialized to the hidden __VIEWSTATE field.
- Controls starts to track ViewState after the it's OnInit.
- The page's OnInit is called after all controls' so at this stage all controls are tracking viewstate.
- Data bound during the page's OnInit and OnLoad will go into ViewState since the control is tracking view state. This means, don't set properties on controls in a page's OnInit and OnLoad if you don't want it to go into viewstate.
- Properties set on a control during the page's OnPreInit, before controls are tracking view state, will not go into ViewState. This can be used to fill controls with data that's easy and cheap to get on every postback.
- When dynamically creating controls (for example in CreateChildControls in a custom control) set all properties before adding the control to the control collection, or else you are at risk of that the control is already tracking ViewState.
Subscribe to:
Posts (Atom)