<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Coeamyd's - HTML</title>
    <link>http://www.coeamyd.net/</link>
    <description>...It ain't easy being green</description>
    <language>en-us</language>
    <copyright>Christoph Herold</copyright>
    <lastBuildDate>Wed, 18 Mar 2009 16:43:48 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 1.9.6264.0</generator>
    <managingEditor>Christoph.Herold@coeamyd.net</managingEditor>
    <webMaster>Christoph.Herold@coeamyd.net</webMaster>
    <item>
      <trackback:ping>http://www.coeamyd.net/Trackback.aspx?guid=a2da5e82-d6aa-42f0-8913-8538cd7502f0</trackback:ping>
      <pingback:server>http://www.coeamyd.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.coeamyd.net/PermaLink,guid,a2da5e82-d6aa-42f0-8913-8538cd7502f0.aspx</pingback:target>
      <dc:creator>Christoph Herold</dc:creator>
      <wfw:comment>http://www.coeamyd.net/CommentView,guid,a2da5e82-d6aa-42f0-8913-8538cd7502f0.aspx</wfw:comment>
      <wfw:commentRss>http://www.coeamyd.net/SyndicationService.asmx/GetEntryCommentsRss?guid=a2da5e82-d6aa-42f0-8913-8538cd7502f0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I just wasted another hour, trying to figure out, what exactly ASP.NET was trying
to tell me, when giving me an <strong>"ASPNET: Make sure that the class defined in
this code file matches the 'inherits' attribute, and that it extends the correct base
class (e.g. Page or UserControl)."</strong> message on compiling my ascx file.
</p>
        <p>
Ok, so I used a custom namespace, but I've done that hundreds of times, so that shouldn't
be the problem. I also had a custom base class inheriting from UserControl. Also,
nothing I haven't done before. So what was the issue now?!
</p>
        <p>
I basically retyped everything concerning the namespace and class names in all files,
but nothing helped. So I reverted to commenting out my code. This helped me find the
issue: I used a
</p>
        <pre>&lt;% if (somethingOrOther) { %&gt; Some code here &lt;% } %&gt;</pre>
        <p>
construct in my ascx-file (Please don't start an argument on whether this is good
practice or not. I know it's not the cleanest way to do things, but that is not the
concern here :-) ), and actually forgot to put in the closing <code>&lt;% } %&gt;</code>.
Ok, my fault, but shouldn't you get a better Compiler message than "ASPNET: Make sure
that the class defined in this code file matches the 'inherits' attribute, and that
it extends the correct base class (e.g. Page or UserControl)."?!
</p>
        <p>
So, if you encouter this error (and believe me, I've had it more than once due to
typos), and are 100% positive you've spelled everything correctly, check for unbalanced
parentheses!
</p>
        <img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=a2da5e82-d6aa-42f0-8913-8538cd7502f0" />
      </body>
      <title>Bogus errors from ASP.NET compiler</title>
      <guid isPermaLink="false">http://www.coeamyd.net/PermaLink,guid,a2da5e82-d6aa-42f0-8913-8538cd7502f0.aspx</guid>
      <link>http://www.coeamyd.net/PermaLink,guid,a2da5e82-d6aa-42f0-8913-8538cd7502f0.aspx</link>
      <pubDate>Wed, 18 Mar 2009 16:43:48 GMT</pubDate>
      <description>&lt;p&gt;
I just wasted another hour, trying to figure out, what exactly ASP.NET was trying
to tell me, when giving me an &lt;strong&gt;"ASPNET: Make sure that the class defined in
this code file matches the 'inherits' attribute, and that it extends the correct base
class (e.g. Page or UserControl)."&lt;/strong&gt; message on compiling my ascx file.
&lt;/p&gt;
&lt;p&gt;
Ok, so I used a custom namespace, but I've done that hundreds of times, so that shouldn't
be the problem. I also had a custom base class inheriting from UserControl. Also,
nothing I haven't done before. So what was the issue now?!
&lt;/p&gt;
&lt;p&gt;
I basically retyped everything concerning the namespace and class names in all files,
but nothing helped. So I reverted to commenting out my code. This helped me find the
issue: I used a
&lt;/p&gt;
&lt;pre&gt;&amp;lt;% if (somethingOrOther) { %&amp;gt; Some code here &amp;lt;% } %&amp;gt;&lt;/pre&gt;
&lt;p&gt;
construct in my ascx-file (Please don't start an argument on whether this is good
practice or not. I know it's not the cleanest way to do things, but that is not the
concern here :-) ), and actually forgot to put in the closing &lt;code&gt;&amp;lt;% } %&amp;gt;&lt;/code&gt;.
Ok, my fault, but shouldn't you get a better Compiler message than "ASPNET: Make sure
that the class defined in this code file matches the 'inherits' attribute, and that
it extends the correct base class (e.g. Page or UserControl)."?!
&lt;/p&gt;
&lt;p&gt;
So, if you encouter this error (and believe me, I've had it more than once due to
typos), and are 100% positive you've spelled everything correctly, check for unbalanced
parentheses!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=a2da5e82-d6aa-42f0-8913-8538cd7502f0" /&gt;</description>
      <comments>http://www.coeamyd.net/CommentView,guid,a2da5e82-d6aa-42f0-8913-8538cd7502f0.aspx</comments>
      <category>.NET;ASP.NET;Development;HTML;Pitfall;Web</category>
    </item>
    <item>
      <trackback:ping>http://www.coeamyd.net/Trackback.aspx?guid=f596bb07-01ec-439a-860a-84830935243c</trackback:ping>
      <pingback:server>http://www.coeamyd.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.coeamyd.net/PermaLink,guid,f596bb07-01ec-439a-860a-84830935243c.aspx</pingback:target>
      <dc:creator>Christoph Herold</dc:creator>
      <wfw:comment>http://www.coeamyd.net/CommentView,guid,f596bb07-01ec-439a-860a-84830935243c.aspx</wfw:comment>
      <wfw:commentRss>http://www.coeamyd.net/SyndicationService.asmx/GetEntryCommentsRss?guid=f596bb07-01ec-439a-860a-84830935243c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Yesterday, I had one of those WTF moments. I had a page with a form for entering two
addresses. Both had the same fields, including a <code>RadioButtonList</code> with
identical items. Since the items are resourced, I decided to optimize the performance
by reusing the <code>ListItem</code>s like so:
</p>
        <pre>ListItem[] items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation.Items.AddRange(items);
this.salutation2.Items.AddRange(items);</pre>
        <p>
Simple eh. Everything seems to be ok. And was I amazed, when I tested it, and I always
got the <code>SelectedItem</code> to be the one selected in <code>salutation2</code>.
I double-checked every location were I was storing the values, in case I forgot to
change the field name after copy/pasting. But everything was correct, as far as I
could tell. I even checked the values submitted by the browser, they were also correct.
</p>
        <p>
Finally, it hit me: The ListItem has a <code>Selected</code> property, and it is used
to find the <code>RadioButtonList</code>s <code>SelectedItem</code> property. And
since I reused the items, the first list parses its items on postback, sets the appropriate <code>ListItem</code>'s <code>Selected</code> property
to <code>true</code>. Same thing happens with the second <code>RadioButtonList</code>.
And since the <code>ListItem</code>s are used in both lists, the last one wins.
</p>
        <p>
So, I changed my code to look like this:
</p>
        <pre>ListItem[] items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation.Items.AddRange(items);
items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation2.Items.AddRange(items);</pre>
        <p>
Now everything works as it should. So next time, be careful when reusing your <code>ListItem</code>s!
</p>
        <img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=f596bb07-01ec-439a-860a-84830935243c" />
      </body>
      <title>Be careful when reusing ListItems</title>
      <guid isPermaLink="false">http://www.coeamyd.net/PermaLink,guid,f596bb07-01ec-439a-860a-84830935243c.aspx</guid>
      <link>http://www.coeamyd.net/PermaLink,guid,f596bb07-01ec-439a-860a-84830935243c.aspx</link>
      <pubDate>Tue, 17 Mar 2009 11:12:24 GMT</pubDate>
      <description>&lt;p&gt;
Yesterday, I had one of those WTF moments. I had a page with a form for entering two
addresses. Both had the same fields, including a &lt;code&gt;RadioButtonList&lt;/code&gt; with
identical items. Since the items are resourced, I decided to optimize the performance
by reusing the &lt;code&gt;ListItem&lt;/code&gt;s like so:
&lt;/p&gt;
&lt;pre&gt;ListItem[] items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation.Items.AddRange(items);
this.salutation2.Items.AddRange(items);&lt;/pre&gt;
&lt;p&gt;
Simple eh. Everything seems to be ok. And was I amazed, when I tested it, and I always
got the &lt;code&gt;SelectedItem&lt;/code&gt; to be the one selected in &lt;code&gt;salutation2&lt;/code&gt;.
I double-checked every location were I was storing the values, in case I forgot to
change the field name after copy/pasting. But everything was correct, as far as I
could tell. I even checked the values submitted by the browser, they were also correct.
&lt;/p&gt;
&lt;p&gt;
Finally, it hit me: The ListItem has a &lt;code&gt;Selected&lt;/code&gt; property, and it is used
to find the &lt;code&gt;RadioButtonList&lt;/code&gt;s &lt;code&gt;SelectedItem&lt;/code&gt; property. And
since I reused the items, the first list parses its items on postback, sets the appropriate &lt;code&gt;ListItem&lt;/code&gt;'s &lt;code&gt;Selected&lt;/code&gt; property
to &lt;code&gt;true&lt;/code&gt;. Same thing happens with the second &lt;code&gt;RadioButtonList&lt;/code&gt;.
And since the &lt;code&gt;ListItem&lt;/code&gt;s are used in both lists, the last one wins.
&lt;/p&gt;
&lt;p&gt;
So, I changed my code to look like this:
&lt;/p&gt;
&lt;pre&gt;ListItem[] items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation.Items.AddRange(items);
items = new ListItem[2];
items[0] = new ListItem(this.GetString("salutation.Mister"), "Mr");
items[1] = new ListItem(this.GetString("salutation.Misses"), "Mrs");
this.salutation2.Items.AddRange(items);&lt;/pre&gt;
&lt;p&gt;
Now everything works as it should. So next time, be careful when reusing your &lt;code&gt;ListItem&lt;/code&gt;s!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=f596bb07-01ec-439a-860a-84830935243c" /&gt;</description>
      <comments>http://www.coeamyd.net/CommentView,guid,f596bb07-01ec-439a-860a-84830935243c.aspx</comments>
      <category>ASP.NET;Development;HTML;Web;Pitfall</category>
    </item>
    <item>
      <trackback:ping>http://www.coeamyd.net/Trackback.aspx?guid=c76428e2-4d76-40d0-a68c-6b3dea04b03c</trackback:ping>
      <pingback:server>http://www.coeamyd.net/pingback.aspx</pingback:server>
      <pingback:target>http://www.coeamyd.net/PermaLink,guid,c76428e2-4d76-40d0-a68c-6b3dea04b03c.aspx</pingback:target>
      <dc:creator>Christoph Herold</dc:creator>
      <wfw:comment>http://www.coeamyd.net/CommentView,guid,c76428e2-4d76-40d0-a68c-6b3dea04b03c.aspx</wfw:comment>
      <wfw:commentRss>http://www.coeamyd.net/SyndicationService.asmx/GetEntryCommentsRss?guid=c76428e2-4d76-40d0-a68c-6b3dea04b03c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Today, I had to make a template for a mailing. I decided to create it as a stationery
for Outlook, since this was the desired way of sending the mails. Not much to it,
one might think. I created the HTML for the template (of course using the dreaded
layout tables, since OL2007 went back to the stone age with its rendering engine),
and copied it and the required images to the stationery folder. Having done that,
the stationery showed in my list and I was able to create a mail using the template.
</p>
        <p>
But what's this?! Were do the gaps in between the images come from?! And why are my
shadows not aligned anymore?! Outlook simply went on and pratically destroyed my layout.
I basically tried everything that came to my mind, trying to fix the gaps: modified
paddings and margins using css, html attributes, added fixed widths and heights, nothing
seemed to work. I even removed all the tables and simply placed two images after one
another, no white space in between. Still, I got my gaps.
</p>
        <p>
When everything seemed hopeless, I decided to simply send the mail the way it was.
Guess what: everything is in perfect shape, when the mail arrives. No gaps, everything
is aligned perfectly. I can even simply forward this mail, and it looks great in the
editor. So the gaps only show, when you first create the mail using the stationery.
Afterwards, everything is as it should be.
</p>
        <p>
&lt;rant&gt;Now that's what I call a consistent user experience! Great job from the
folks at Microsoft. I wasted a whole day trying to work around this bug.&lt;/rant&gt;
</p>
        <p>
And by the way, using stationery is probably not the best solution, since Outlook
completely reformats your code and places all those unneccessary MSO* css styles in
your mail's code. So if something goes wrong with your mail, you might consider NOT
using Outlook to send it in the first place.<br /></p>
        <img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=c76428e2-4d76-40d0-a68c-6b3dea04b03c" />
      </body>
      <title>Outlook 2007 stationeries and image spacing</title>
      <guid isPermaLink="false">http://www.coeamyd.net/PermaLink,guid,c76428e2-4d76-40d0-a68c-6b3dea04b03c.aspx</guid>
      <link>http://www.coeamyd.net/PermaLink,guid,c76428e2-4d76-40d0-a68c-6b3dea04b03c.aspx</link>
      <pubDate>Sun, 14 Dec 2008 22:50:02 GMT</pubDate>
      <description>&lt;p&gt;
Today, I had to make a template for a mailing. I decided to create it as a stationery
for Outlook, since this was the desired way of sending the mails. Not much to it,
one might think. I created the HTML for the template (of course using the dreaded
layout tables, since OL2007 went back to the stone age with its rendering engine),
and copied it and the required images to the stationery folder. Having done that,
the stationery showed in my list and I was able to create a mail using the template.
&lt;/p&gt;
&lt;p&gt;
But what's this?! Were do the gaps in between the images come from?! And why are my
shadows not aligned anymore?! Outlook simply went on and pratically destroyed my layout.
I basically tried everything that came to my mind, trying to fix the gaps: modified
paddings and margins using css, html attributes, added fixed widths and heights, nothing
seemed to work. I even removed all the tables and simply placed two images after one
another, no white space in between. Still, I got my gaps.
&lt;/p&gt;
&lt;p&gt;
When everything seemed hopeless, I decided to simply send the mail the way it was.
Guess what: everything is in perfect shape, when the mail arrives. No gaps, everything
is aligned perfectly. I can even simply forward this mail, and it looks great in the
editor. So the gaps only show, when you first create the mail using the stationery.
Afterwards, everything is as it should be.
&lt;/p&gt;
&lt;p&gt;
&amp;lt;rant&amp;gt;Now that's what I call a consistent user experience! Great job from the
folks at Microsoft. I wasted a whole day trying to work around this bug.&amp;lt;/rant&amp;gt;
&lt;/p&gt;
&lt;p&gt;
And by the way, using stationery is probably not the best solution, since Outlook
completely reformats your code and places all those unneccessary MSO* css styles in
your mail's code. So if something goes wrong with your mail, you might consider NOT
using Outlook to send it in the first place.&lt;br&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://www.coeamyd.net/aggbug.ashx?id=c76428e2-4d76-40d0-a68c-6b3dea04b03c" /&gt;</description>
      <comments>http://www.coeamyd.net/CommentView,guid,c76428e2-4d76-40d0-a68c-6b3dea04b03c.aspx</comments>
      <category>HTML;Mail;Outlook;Web</category>
    </item>
  </channel>
</rss>