Tag Archives: Web Development
Working with ASP.NET AJAX UpdatePanel Properties video by Dan Wahlin
This video tutorial demonstrates the affect that the UpdatePanel's UpdateMode and ChildrenAsTriggers properties have on updating a panel's content. The video starts out by discussing the UpdateMode property and shows why you may want to know about it when using … Continue Reading
Simple ASP.NET 2.0 Tips and Tricks that You May (or may not) have Heard About by Dan Wahlin
ASP.NET 2.0 is an awesome framework for developing Web applications. If you've worked with it for awhile then that's no secret. It offers some great new features that you can implement with a minimal amount of code. I wanted to start … Continue Reading
Recursive FindControl by Michael Palermo
Need to find a control anywhere on the page or in a template? Here is the code to find it recursively. This example assumes the code is located in a custom base page.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
<span style="color: teal;"> 1</span> <span style="color: blue;">public</span> T FindControl<T>(<span style="color: blue;">string</span> id) where T : Control
<span style="color: teal;"> 2</span> {
<span style="color: teal;"> 3</span> <span style="color: blue;">return</span> FindControl<T>(Page, id);
<span style="color: teal;"> 4</span> }
<span style="color: teal;"> 5</span>
<span style="color: teal;"> 6</span> <span style="color: blue;">public</span> <span style="color: blue;">static</span> T FindControl<T>(Control startingControl, <span style="color: blue;">string</span> id) where T : Control
<span style="color: teal;"> 7</span> {
<span style="color: teal;"> 8</span> <span style="color: green;">// this is null by default</span>
<span style="color: teal;"> 9</span> T found = <span style="color: blue;">default</span>(T);
<span style="color: teal;"> 10</span>
<span style="color: teal;"> 11</span> <span style="color: blue;">int</span> controlCount = startingControl.Controls.Count;
<span style="color: teal;"> 12</span>
<span style="color: teal;"> 13</span> <span style="color: blue;">if</span> (controlCount > <span style="color: maroon;">0</span>)
<span style="color: teal;"> 14</span> {
<span style="color: teal;"> 15</span> <span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = <span style="color: maroon;">0</span>; i < controlCount; i++)
<span style="color: teal;"> 16</span> {
<span style="color: teal;"> 17</span> Control activeControl = startingControl.Controls[i];
<span style="color: teal;"> 18</span> <span style="color: blue;">if</span> (activeControl <span style="color: blue;">is</span> T)
<span style="color: teal;"> 19</span> {
<span style="color: teal;"> 20</span> found = startingControl.Controls[i] <span style="color: blue;">as</span> T;
<span style="color: teal;"> 21</span> <span style="color: blue;">if</span> (<span style="color: blue;">string</span>.Compare(id, found.ID, <span style="color: maroon;">true</span>) == <span style="color: maroon;">0</span>) <span style="color: blue;">break</span>;
<span style="color: teal;"> 22</span> <span style="color: blue;">else</span> found = <span style="color: blue;">null</span>;
<span style="color: teal;"> 23</span> }
<span style="color: teal;"> 24</span> <span style="color: blue;">else</span>
<span style="color: teal;"> 25</span> {
<span style="color: teal;"> 26</span> found = FindControl<T>(activeControl, id);
<span style="color: teal;"> 27</span> <span style="color: blue;">if</span> (found != <span style="color: blue;">null</span>) <span style="color: blue;">break</span>;
<span style="color: teal;"> 28</span> }
<span style="color: teal;"> 29</span> }
<span style="color: teal;"> 30</span> }
<span style="color: teal;"> 31</span> <span style="color: blue;">return</span> found;
<span style="color: teal;"> 32</span> } |
Video: Creating a Web Service with Windows Communication Foundation (WCF)
My good buddy Lorin Thwaits invited me to give a WCF talk at the Vista launch event on Feb. 3rd for the Arizona .NET User Group. Thanks to everyone who attended…I had a lot of fun and met some great … Continue Reading
Using the ASP.NET AJAX UpdatePanel Triggers and PageRequestManager video by Dan Wahlin
Microsoft's ASP.NET AJAX technology provides a quick and simple way to add AJAX capabilities into new or existing Web pages. In this video tutorial I discuss how to use the UpdatePanel, refresh it using triggers and detect when it has … Continue Reading
