﻿<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Daniel Balla's Blog</title>
    <description>&lt;div style="font-family: Courier New; font-size: 10pt; color: black; background: white;line-height: 13pt;"&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; Various posts on software design and development,&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; in particular .NET Framework, and other random thoughts&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: gray;"&gt;///&lt;/span&gt;&lt;span style="color: green;"&gt; &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;[&lt;span style="color: teal;"&gt;Serializable&lt;/span&gt;]&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;&lt;span style="color: blue;"&gt;class&lt;/span&gt; &lt;span style="color: teal;"&gt;Blog&lt;/span&gt;&amp;lt;T&amp;gt; &lt;span style="color: blue;"&gt;where&lt;/span&gt; T : ASP.NET, Ajax, WCF, SOA, &lt;span style="color: blue;"&gt;new&lt;/span&gt;()&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;{&lt;/pre&gt; &lt;pre style="margin: 0px;"&gt;}&lt;/pre&gt; &lt;/div&gt;</description>
    <link>http://www.serializable.co.uk/Blog/tabid/54/BlogId/1/Default.aspx</link>
    <language>en-US</language>
    <managingEditor>daniel@serializable.co.uk</managingEditor>
    <webMaster>daniel@serializable.co.uk</webMaster>
    <pubDate>Thu, 20 Nov 2008 21:35:54 GMT</pubDate>
    <lastBuildDate>Thu, 20 Nov 2008 21:35:54 GMT</lastBuildDate>
    <docs>http://backend.userland.com/rss</docs>
    <generator>Blog RSS Generator Version 3.4.0.39853</generator>
    <item>
      <title>Row level validation in a gridview</title>
      <description>&lt;p&gt;A couple days ago a friend asked me how can you make the ASP.NET validators validate the contents of a gridview at row level, so that each row works independently. For example, in the grid below use a requiredfieldvalidator on each row so that the &lt;span style="font-style: italic"&gt;Save &lt;/span&gt;button would validate the description textbox on the same row, but wouldn’t validate any of the other rows’ descriptions.&lt;br /&gt;
&lt;br /&gt;
&lt;img alt="" src="http://www.serializable.co.uk/download/gridvalidation.jpg" /&gt;&lt;br /&gt;
&lt;br /&gt;
In this case, clicking the save button in the “Dairy products” row would cause the validation to suppress the postback, but clicking the save button of any other row wouldn’t.&lt;br /&gt;
The solution is simple: use the validation group bound to a unique row identifier. In our example (which displays the contents of the Categories table of the Northwind database) the binding would look like:&lt;/p&gt;
&lt;p&gt;&lt;asp:TextBox Width="300px" ID="txtDescription" runat="server" Text='&lt;%# Bind&lt;"Description"&gt; %&gt;' /&gt;&lt;br /&gt;
&lt;asp:RequiredFieldValidator ID="reqDescription" runat="server" ControlToValidate="txtDescription" ErrorMessage="*" ValidationGroup='&lt;%# Bind&lt;"CategoryID"&gt; %&gt;' /&gt;&lt;br /&gt;
&lt;asp:Button ID="butSave" runat="server" Text="Save" ValidationGroup='&lt;%# Bind&lt;"CategoryID"&gt; %&gt;' /&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;asp:textbox id="txtDescription" text="" runat="server" width="300px"&gt;&lt;asp:TextBox Width="300px" ID="txtDescription" runat="server" Text='&lt;%# Bind&lt;"Description"&gt; %&gt;' /&gt;&lt;br /&gt;
&lt;asp:RequiredFieldValidator ID="reqDescription" runat="server" ControlToValidate="txtDescription" ErrorMessage="*" ValidationGroup='&lt;%# Bind&lt;"CategoryID"&gt; %&gt;' /&gt;&lt;br /&gt;
&lt;asp:Button ID="butSave" runat="server" Text="Save" ValidationGroup='&lt;%# Bind&lt;"CategoryID"&gt; %&gt;' /&gt;&lt;br /&gt;
&lt;/asp:textbox&gt;&lt;a href="http://www.serializable.co.uk/download/gridvalidation.zip"&gt;Download Sample Code&lt;/a&gt;&lt;/p&gt;</description>
      <link>http://www.serializable.co.uk/Blog/tabid/54/EntryID/6/Default.aspx</link>
      <author>daniel@serializable.co.uk</author>
      <comments>http://www.serializable.co.uk/Blog/tabid/54/EntryID/6/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.serializable.co.uk/Default.aspx?tabid=54&amp;EntryID=6</guid>
      <pubDate>Fri, 23 Mar 2007 18:57:03 GMT</pubDate>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.serializable.co.uk/DesktopModules/Blog/Trackback.aspx?id=6</trackback:ping>
    </item>
    <item>
      <title>Script controls may not be registered before PreRender</title>
      <description>&lt;p&gt;This is neither a very common scenario nor a major finding, just a small reminder/warning to spare you a little debugging for one of those things that are fairly obvious yet could take some time to see.&lt;br /&gt;
While helping a friend figure out why his ASP.NET no longer works after "atlasising" it I came across this issue:&lt;br /&gt;
The page was throwing the following exception:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-weight: bold; font-style: italic"&gt;Script controls may not be registered before PreRender.&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic"&gt;Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style: italic"&gt;Exception Details: System.InvalidOperationException: Script controls may not be registered before PreRender.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style: italic"&gt;Source Error:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style: italic"&gt;An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style: italic"&gt;Stack Trace:&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-style: italic"&gt;[InvalidOperationException: Script controls may not be registered before PreRender.]&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic"&gt;Microsoft.Web.UI.ScriptControlManager.RegisterScriptControl(TScriptControl scriptControl) +144&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic"&gt;Microsoft.Web.UI.UpdateProgress.OnPreRender(EventArgs e) +140&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic"&gt;System.Web.UI.Control.PreRenderRecursiveInternal() +77&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic"&gt;System.Web.UI.Control.PreRenderRecursiveInternal() +161&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic"&gt;System.Web.UI.Control.PreRenderRecursiveInternal() +161&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic"&gt;System.Web.UI.Control.PreRenderRecursiveInternal() +161&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-style: italic"&gt;System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
As the page worked before it had the atlas references and an update panel added (and out of laziness) instead of properly reading the source code I proffered to google the error and the only relevant result was http://forums.asp.net/thread/1471314.aspx where the suggestion was that an older version of the DLL might be cached somewhere. Here is where I went wrong and spent a lot of time clearing and rebuilding. On a second look, I found that the page's OnPreRender method was overridden and it didn't call the base OnPreRender method therefore loosing some handlers. Obviously this mistake didn't do much difference before atlas came into play but it did afterwards because the Atlas ScriptControlManager's RegisterScriptControl method doesn't register the control but after prerender (by checking a flag it sets on prerender)&lt;br /&gt;
&lt;br /&gt;
public void RegisterScriptControl&lt;tscriptcontrol&gt;&lt;/tscriptcontrol&gt;(TScriptControl scriptControl) where TScriptControl: Control, IScriptControl&lt;br /&gt;
{&lt;br /&gt;
if (scriptControl == null)&lt;br /&gt;
{&lt;br /&gt;
throw new ArgumentNullException("scriptControl");&lt;br /&gt;
}&lt;br /&gt;
if (!this._pagePreRenderRaised)&lt;br /&gt;
{&lt;br /&gt;
throw new InvalidOperationException(AtlasWeb.ScriptControlManager_RegisterScriptControlTooEarly);&lt;br /&gt;
}&lt;br /&gt;
this.ScriptControls.Add(scriptControl);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
public void OnPagePreRender(object sender, EventArgs e)&lt;br /&gt;
{&lt;br /&gt;
this._pagePreRenderRaised = true;&lt;br /&gt;
}&lt;/p&gt;</description>
      <link>http://www.serializable.co.uk/Blog/tabid/54/EntryID/5/Default.aspx</link>
      <author>daniel@serializable.co.uk</author>
      <comments>http://www.serializable.co.uk/Blog/tabid/54/EntryID/5/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.serializable.co.uk/Default.aspx?tabid=54&amp;EntryID=5</guid>
      <pubDate>Wed, 22 Nov 2006 18:55:59 GMT</pubDate>
      <slash:comments>12</slash:comments>
      <trackback:ping>http://www.serializable.co.uk/DesktopModules/Blog/Trackback.aspx?id=5</trackback:ping>
    </item>
    <item>
      <title>Unable to preview web service </title>
      <description>&lt;p&gt;Seldom, but still a possible scenario: when trying to preview the generated service description for an asmx web service (both .NET 1.1 and .NET 2.0) you might get an error that is not very well described:&lt;br /&gt;
&lt;br /&gt;
Line 1334:    OperationBinding FindHttpBinding(string verb) {&lt;br /&gt;
Line 1335:        foreach (ServiceDescription description in serviceDescriptions) {&lt;br /&gt;
Line 1336:            foreach (Binding binding in description.Bindings) {&lt;br /&gt;
Line 1337:                HttpBinding httpBinding = (HttpBinding)binding.Extensions.Find(typeof(HttpBinding));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The real issue is that in your web application’s web.config file in the pages element you probably have the &lt;span style="font-weight: bold;"&gt;autoEventWireup &lt;/span&gt;attribute set to false&lt;br /&gt;
&lt;pages … autoEventWireup="false"…&lt;br /&gt;
&lt;br /&gt;
If you want to trace the problem, you can open the DefaultWsdlHelpGenerator.aspx file (located under &lt;span style="font-style: italic;"&gt;%windir\Microsoft.NET\Framework\[version]\CONFIG\DefaultWsdlHelpGenerator.aspx&lt;/span&gt;) and you would notice that the error is that the serviceDescriptions member is used without being initialized (therefore the null object reference exception). Looking up in the page you notice that the serviceDescriptions member is initialized&lt;br /&gt;
(as:&lt;br /&gt;
serviceDescriptions = (ServiceDescriptionCollection) Context.Items["wsdlsWithPost"];&lt;br /&gt;
or&lt;br /&gt;
serviceDescriptions = (ServiceDescriptionCollection) Context.Items["wsdls"];)&lt;br /&gt;
in the Page_Load method. However, because your settings disable the autoeventwireup that prevents the Page_Load methods from being called (it is not explicitly wired to the page load event so it relies entirely on the autoeventwireup feature).&lt;br /&gt;
&lt;br /&gt;
Surely this isn’t a big finding and it wouldn’t save you more than 5 minutes of debugging but it is worth mentioning because it is a “red wiring” in the framework.&lt;/p&gt;</description>
      <link>http://www.serializable.co.uk/Blog/tabid/54/EntryID/4/Default.aspx</link>
      <author>daniel@serializable.co.uk</author>
      <comments>http://www.serializable.co.uk/Blog/tabid/54/EntryID/4/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.serializable.co.uk/Default.aspx?tabid=54&amp;EntryID=4</guid>
      <pubDate>Tue, 21 Nov 2006 13:09:38 GMT</pubDate>
      <slash:comments>1</slash:comments>
      <trackback:ping>http://www.serializable.co.uk/DesktopModules/Blog/Trackback.aspx?id=4</trackback:ping>
    </item>
    <item>
      <title>Event handler code snippet</title>
      <description>&lt;p&gt;Indeed, most times you write the events at a time, maybe in a region and the trigger methods afterwards in another region; but then you do the same with local fields and properties, and yet the prop snippet comes in handy. Therefore I thought a simple &lt;a href="http://www.serializable.co.ukhttp://www.serializable.co.uk/download/snippets/event.zip"&gt;event code snippet&lt;/a&gt; would be useful. You can &lt;a href="http://www.serializable.co.ukhttp://www.serializable.co.uk/download/snippets/event.zip"&gt;download it here&lt;/a&gt; and then copy it to your Program Files\Microsoft Visual Studio 8\VC#\Snippets\1033\Visual C#\ directory&lt;/p&gt;
&lt;p&gt;or, copy/paste from below:&lt;br /&gt;
&lt;br /&gt;
&lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;?xml version="1.0" encoding="utf-8" ?&gt;&lt;br /&gt;
&lt;CodeSnippets xmlns="&lt;a href="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet"&gt;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&lt;/a&gt;"&gt;&lt;br /&gt;
&lt;CodeSnippet Format="1.0.0"&gt;&lt;br /&gt;
&lt;Header&gt;&lt;br /&gt;
&lt;Title&gt;event&lt;/Title&gt;&lt;br /&gt;
&lt;Shortcut&gt;event&lt;/Shortcut&gt;&lt;br /&gt;
&lt;Description&gt;Code snippet to created and document an event&lt;/Description&gt;&lt;br /&gt;
&lt;Author&gt;Daniel Balla&lt;/Author&gt;&lt;br /&gt;
&lt;SnippetTypes&gt;&lt;br /&gt;
&lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;&lt;br /&gt;
&lt;/SnippetTypes&gt;&lt;br /&gt;
&lt;/Header&gt;&lt;br /&gt;
&lt;Snippet&gt;&lt;br /&gt;
&lt;Declarations&gt;&lt;br /&gt;
&lt;Literal&gt;&lt;br /&gt;
&lt;ID&gt;event&lt;/ID&gt;&lt;br /&gt;
&lt;ToolTip&gt;Event name&lt;/ToolTip&gt;&lt;br /&gt;
&lt;Default&gt;MyEvent&lt;/Default&gt;&lt;br /&gt;
&lt;/Literal&gt;&lt;br /&gt;
&lt;Literal&gt;&lt;br /&gt;
&lt;ID&gt;eventArgs&lt;/ID&gt;&lt;br /&gt;
&lt;ToolTip&gt;Event arguments type&lt;/ToolTip&gt;&lt;br /&gt;
&lt;Default&gt;EventArgs&lt;/Default&gt;&lt;br /&gt;
&lt;/Literal&gt;&lt;br /&gt;
&lt;/Declarations&gt;&lt;br /&gt;
&lt;Code Language="csharp"&gt;&lt;![CDATA[#region Event Handler $event$ ($eventArgs$)&lt;br /&gt;
/// &lt;summary&gt;&lt;br /&gt;
/// This event is fired when |&lt;br /&gt;
/// &lt;/summary&gt;&lt;br /&gt;
public event EventHandler $event$;&lt;br /&gt;
#endregion&lt;br /&gt;
#region Event notification $event$&lt;br /&gt;
/// &lt;summary&gt;&lt;br /&gt;
/// Notifies the listeners of the $event$ event&lt;br /&gt;
/// &lt;/summary&gt;&lt;br /&gt;
/// &lt;param name="e"&gt;The argument to send to the listeners&lt;/param&gt;&lt;br /&gt;
protected virtual void On$event$($eventArgs$ e) {&lt;br /&gt;
if($event$ != null) {&lt;br /&gt;
$event$(this,e);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
#endregion$end$]]&gt;&lt;br /&gt;
&lt;/Code&gt;&lt;br /&gt;
&lt;/Snippet&gt;&lt;br /&gt;
&lt;/CodeSnippet&gt;&lt;br /&gt;
&lt;/CodeSnippets&gt;&lt;/p&gt;</description>
      <link>http://www.serializable.co.uk/Blog/tabid/54/EntryID/2/Default.aspx</link>
      <author>daniel@serializable.co.uk</author>
      <comments>http://www.serializable.co.uk/Blog/tabid/54/EntryID/2/Default.aspx#Comments</comments>
      <guid isPermaLink="true">http://www.serializable.co.uk/Default.aspx?tabid=54&amp;EntryID=2</guid>
      <pubDate>Mon, 02 Oct 2006 21:55:16 GMT</pubDate>
      <slash:comments>0</slash:comments>
      <trackback:ping>http://www.serializable.co.uk/DesktopModules/Blog/Trackback.aspx?id=2</trackback:ping>
    </item>
  </channel>
</rss>