About

I'm Mike Pope. I live in the Seattle area. I've been a technical writer and editor for over 30 years. I'm interested in software, language, music, movies, books, motorcycles, travel, and ... well, lots of stuff.

Read more ...

Blog Search


(Supports AND)

Google Ads

Feed

Subscribe to the RSS feed for this blog.

See this post for info on full versus truncated feeds.

Quote

Seven Deadly Sins Rated
Sloth: Sloth is cheap, and easy to get. B+

Gluttony: Gluttony can be hard work. C+

Wrath: Unsociable, bad on the nerves, and drives property values down. D

Lust: Ah, lust. Putting the "deadly" back into the Seven Deadly Sins. B

Pride: My high school counselors were always pushing self-esteem on me. Were they pawns of the Adversary? C

Envy: All you have to do is covet something of someone else's and boom, you're a brimstone hors d'oeuvre. C-

Avarice: Greedy people inevitably end up looking goofy in public. D


Lore Fitzgerald Sjöberg



Navigation





<November 2021>
SMTWTFS
31123456
78910111213
14151617181920
21222324252627
2829301234
567891011

Categories

  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  
  RSS  

Contact Me

Email me

Blog Statistics

Dates
First entry - 6/27/2003
Most recent entry - 9/13/2021

Totals
Posts - 2638
Comments - 2646
Hits - 2,426,637

Averages
Entries/day - 0.39
Comments/entry - 1.00
Hits/day - 361

Updated every 30 minutes. Last: 10:15 PM Pacific


  04:54 PM

When you read a page on MSDN, you can both rate it and enter comments. Other people can see the ratings, but the comments are not visible to all.

Now and again we'll have a look at a topic and wonder about the ratings. (Well, we generally wonder only about bad ratings. :-) ) There have been a few that we thought were pretty useful topics that have gotten low ratings. Then when we look at the comments, we'll find out that, oh, say, the code in the topic has a bug in it. There's a way to get yerself a low rating.

And do you want a really, really low rating? How about if you leave the sample code out altogether? Uh ... oops. We did this in a topic I was looking at today[1]:

How to: Locate the Web Forms Controls on a Page by Walking the Controls Collection

The comments were surprisingly un-vicious, considering. Anyway, here's the missing code:
' VB
<%@ Page Language="VB" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">
<title>Locate the Web Forms Controls on a Page by Walking the Controls Collection</title>
</head>

<script runat="server">
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Dim allTextBoxValues As String = ""
Dim c As Control
Dim childc As Control
For Each c In Page.Controls
For Each childc In c.Controls
If TypeOf childc Is TextBox Then
allTextBoxValues &= CType(childc, TextBox).Text & ","
End If
Next
Next
If allTextBoxValues <> "" Then
Label1.Text = allTextBoxValues
End If
End Sub
</script>

<body>
<form id="form1" runat="server">
<asp:Button id="Button1" runat=server />
<asp:Label id=Label1 runat=server></asp:Label>
</form>
</body>
</html>
// C#
<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >

<head runat="server">
<title>Locate the Web Forms Controls on a Page by Walking the Controls Collection</title>
</head>
<script runat="server">
private void Button1_Click(object sender, System.EventArgs e)
{
string allTextBoxValues = "";
foreach (Control c in Page.Controls)
{
foreach (Control childc in c.Controls)
{
if (childc is TextBox)
{
allTextBoxValues += ((TextBox)childc).Text + ",";
}
}
}
if (allTextBoxValues != "")
{
Label1.Text = allTextBoxValues;
}
}

</script>
<body>
<form id="form1" runat="server">
<asp:Button id="Button1" runat=server />
<asp:Label id=Label1 runat=server></asp:Label>
</form>
</body>
</html>
[1] It's not that we left it out, of course. There was some build problem and the code sample was dropped out of the topic. Same effect either way, tho.

[categories]   , ,

|