<?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>Dave Arlin - Bloggin' - ASP.Net Page Life Cycle</title>
    <link>http://blog.davearlin.com/</link>
    <description>learn forever</description>
    <language>en-us</language>
    <copyright>Dave Arlin</copyright>
    <lastBuildDate>Fri, 13 Feb 2009 06:42:16 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>dave@davearlin.com</managingEditor>
    <webMaster>dave@davearlin.com</webMaster>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=990734e2-d0f6-4b0e-ac1e-070db6e477c6</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,990734e2-d0f6-4b0e-ac1e-070db6e477c6.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,990734e2-d0f6-4b0e-ac1e-070db6e477c6.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=990734e2-d0f6-4b0e-ac1e-070db6e477c6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h1>
          <font face="Verdana">
            <font size="2">Something New Everyday!</font>
            <br />
          </font>
        </h1>
        <p>
          <font face="Verdana"> Earlier today, I ran into a rather annoying issue that was painfully
hard to debug and narrow down the cause. While debugging some functionality that executed
on a postback, I had a breakpoint in my page .cs located at the start of our old friend,
Page_Load. So, it turns out my logic was working just fine on the postback call, but
once that Page_Load handler finished its run, low and behold, my breakpoint was hit
again?! 
<br /></font>
        </p>
        <h1>
          <font face="Verdana">
            <font size="2">Why Twice?</font>
            <br />
          </font>
        </h1>
        <p>
          <font face="Verdana"> This second run through was not being treated as a postback,
so a lot of my page initialization code was firing and undoing some changes that were
just done on my postback. After a painfully long time of commenting out C# code and
javascript and not being able to reproduce the problem, I finally narrowed it down
to the following line in my .aspx markup. </font>
        </p>
        <h4>
          <font face="Verdana">
            <font color="#0000ff">&lt;<font color="#000000">img src</font>="" <font color="#000000">width </font>=
"<font color="#000000">100</font>" <font color="#000000">height </font>= "<font color="#000000">100</font>"/&gt;</font>
          </font>
        </h4>
        <h1>
          <font size="2" face="Verdana">At Least It's an Easy Fix</font>
          <br />
        </h1>
        <p>
          <font face="Verdana"> Well it turns out that setting the src attribute to blank indicates
that you are self referencing the page that the img resides on. Thus, my Page_Load
event would fire a second time. If you're wondering why there is a blank src attribute,
the intention was to populate it via javascript at a later point. The potential fixes
are:</font>
        </p>
        <p>
          <font face="Verdana">1) Not specifying the src attribute at all. This however violates
w3c standards and will also give you annoying warning messages within Visual Studio<br /></font>
        </p>
        <p>
          <font face="Verdana">2) Just add a spacer image and set the src attribute to that. </font>
        </p>
        <img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=990734e2-d0f6-4b0e-ac1e-070db6e477c6" />
      </body>
      <title>The evil self referencing &amp;lt;img&amp;gt;</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,990734e2-d0f6-4b0e-ac1e-070db6e477c6.aspx</guid>
      <link>http://blog.davearlin.com/2009/02/13/TheEvilSelfReferencingLtimggt.aspx</link>
      <pubDate>Fri, 13 Feb 2009 06:42:16 GMT</pubDate>
      <description>&lt;h1&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;Something New Everyday!&lt;/font&gt;
&lt;br&gt;
&lt;/font&gt;
&lt;/h1&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt; Earlier today, I ran into a rather annoying issue that was painfully
hard to debug and narrow down the cause. While debugging some functionality that executed
on a postback, I had a breakpoint in my page .cs located at the start of our old friend,
Page_Load. So, it turns out my logic was working just fine on the postback call, but
once that Page_Load handler finished its run, low and behold, my breakpoint was hit
again?! 
&lt;br&gt;
&lt;/font&gt;
&lt;/p&gt;
&lt;h1&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;Why Twice?&lt;/font&gt;
&lt;br&gt;
&lt;/font&gt;
&lt;/h1&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt; This second run through was not being treated as a postback,
so a lot of my page initialization code was firing and undoing some changes that were
just done on my postback. After a painfully long time of commenting out C# code and
javascript and not being able to reproduce the problem, I finally narrowed it down
to the following line in my .aspx markup. &lt;/font&gt;
&lt;/p&gt;
&lt;h4&gt;
&lt;font face="Verdana"&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;font color="#000000"&gt;img src&lt;/font&gt;="" &lt;font color="#000000"&gt;width &lt;/font&gt;=
"&lt;font color="#000000"&gt;100&lt;/font&gt;" &lt;font color="#000000"&gt;height &lt;/font&gt;= "&lt;font color="#000000"&gt;100&lt;/font&gt;"/&amp;gt;&lt;/font&gt;&lt;/font&gt;
&lt;/h4&gt;
&lt;h1&gt;&lt;font size="2" face="Verdana"&gt;At Least It's an Easy Fix&lt;/font&gt;
&lt;br&gt;
&lt;/h1&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt; Well it turns out that setting the src attribute to blank indicates
that you are self referencing the page that the img resides on. Thus, my Page_Load
event would fire a second time. If you're wondering why there is a blank src attribute,
the intention was to populate it via javascript at a later point. The potential fixes
are:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt;1) Not specifying the src attribute at all. This however violates
w3c standards and will also give you annoying warning messages within Visual Studio&lt;br&gt;
&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt;2) Just add a spacer image and set the src attribute to that. &lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=990734e2-d0f6-4b0e-ac1e-070db6e477c6" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,990734e2-d0f6-4b0e-ac1e-070db6e477c6.aspx</comments>
      <category>ASP.Net Page Life Cycle</category>
    </item>
  </channel>
</rss>