{"id":37,"date":"2003-05-10T00:50:07","date_gmt":"2003-05-10T00:50:07","guid":{"rendered":"http:\/\/bdragon.com\/?p=37"},"modified":"2011-03-30T02:57:27","modified_gmt":"2011-03-30T08:57:27","slug":"asp-net-1-0-to-1-1-upgrade-issues","status":"publish","type":"post","link":"https:\/\/bdragon.com\/lair\/2003\/05\/asp-net-1-0-to-1-1-upgrade-issues\/","title":{"rendered":"ASP.NET 1.0 To 1.1 Upgrade Issues"},"content":{"rendered":"<div class=\"entry\">\n<p>This is some technical\/web development stuff&#8230; I am just posting it up here in case it can help anyone who comes across it down the road.<\/p>\n<p><!--more--><\/p>\n<p>\nI am currently developing web sites in ASP.NET (using C# and code-behind\/VS.NET) and have been very pleased with it and the ease with which many things can be done when compared to &#8220;before&#8221;.<\/p>\n<p>When I upgraded my .NET version from 1.0 to 1.1 I came across some issues that I hadn&#8217;t\/haven&#8217;t seen mentioned anywhere that I could find&#8230; so just in case these can help somebody, I am putting some rambing type of descriptions here.<\/p>\n<pre>ASP.NET 1.0 -&gt; ASP.NET 1.1 Upgrade Issues (and fixes):\r\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/pre>\n<p>ERROR OR PROBLEM:<\/p>\n<blockquote>\n<p>\nBizarre(?) runtime error &#8212;<br \/>\nParser Error Message: Type &#8216;System.Web.HttpBrowserCapabilities&#8217; does not inherit from &#8216;System.Web.Mobile.MobileCapabilities&#8217;.\n<\/p>\n<\/blockquote>\n<p>SOLUTION:<\/p>\n<blockquote>\n<p>\nHad to uncomment\/remove the browsercaps &#8220;result&#8221; element in web.config file\n<\/p>\n<\/blockquote>\n<p>COMMENTS:<\/p>\n<blockquote>\n<p>\nDoesn&#8217;t seem to have affected\/broken anything else (so far?)\n<\/p>\n<\/blockquote>\n<pre>&lt;browserCaps&gt;\r\n&lt;!-- result type=\"System.Web.HttpBrowserCapabilities\" \/ --&gt;<\/pre>\n<p><code>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<\/code><br \/>\nERROR OR PROBLEM:<\/p>\n<blockquote>\n<p>\nPaging on datagrids no longer worked, though it worked before, (this also might affect &#8220;linkbuttons&#8221;? I don&#8217;t use them..) and\/or javascript errors on pages w\/datagrid or linkbuttons on them.  The source\/cause of the problem was a combination of a &#8220;template&#8221; system whereby my webforms were using a &#8220;template&#8221; class derived from system.web.ui.page and the javascript &#8220;dopostback&#8221; code that is generated to post the form to the server&#8230; I had run into this issue before with ASP.NET 1.0 when using an &#8220;autopostback&#8221; dropdownlist which wouldn&#8217;t work automatically in Mozilla until I also implemented the solution below&#8230;\n<\/p>\n<\/blockquote>\n<p>SOLUTION:<\/p>\n<blockquote>\n<p>\nThe dopostback javascript &#8220;breaks&#8221; due to the fact that a control name (like &#8220;ctl0:&#8221; or &#8220;ctl0_&#8221;) is added before the server-side form tag (in the templating \/ inherit from system.web.ui.page system).  Here is a sample full html page which illustrates the problem:\n<\/p>\n<\/blockquote>\n<pre>-------------------------------------------------------------------\r\n&lt;html&gt;\r\n&lt;head&gt;\r\n&lt;body&gt;\r\n&lt;form name=\"_ctl0:frmPage\" method=\"post\" action=\"list_emails.aspx\" id=\"_ctl0_frmPage\"&gt;\r\n&lt;input type=\"hidden\" name=\"__EVENTTARGET\" value=\"\" \/&gt;\r\n&lt;input type=\"hidden\" name=\"__EVENTARGUMENT\" value=\"\" \/&gt;\r\n&lt;script language=\"javascript\"&gt;\r\n&lt;!--\r\nfunction __doPostBack(eventTarget, eventArgument) {\r\nvar theform;\r\nif (window.navigator.appName.toLowerCase().indexOf(\"netscape\") &gt; -1) {\r\ntheform = document.forms[\"_ctl0:frmPage\"];\r\n}\r\nelse {\r\n\/\/this is the line causing the problem (in non-netscape browsers at least):\r\ntheform = document._ctl0:frmPage;\r\n}\r\ntheform.__EVENTTARGET.value = eventTarget.split(\"$\").join(\":\");\r\ntheform.__EVENTARGUMENT.value = eventArgument;\r\ntheform.submit();\r\n}\r\n\/\/ --&gt;\r\n&lt;\/script&gt;\r\n&lt;br clear=\"all\" \/&gt;\r\n&lt;table&gt;\r\n&lt;tr&gt;\r\n&lt;td&gt;&lt;span&gt;1&lt;\/span&gt;&amp;nbsp;\r\n&lt;a href=\"javascript:__doPostBack('_ctl0$dgData$_ctl1$_ctl1','')\"&gt;2&lt;\/a&gt;&amp;nbsp;\r\n&lt;a href=\"javascript:__doPostBack('_ctl0$dgData$_ctl1$_ctl2','')\"&gt;3&lt;\/a&gt;&amp;nbsp;\r\n&lt;a href=\"javascript:__doPostBack('_ctl0$dgData$_ctl1$_ctl10','')\"&gt;...&lt;\/a&gt;&lt;\/td&gt;\r\n&lt;\/tr&gt;\r\n&lt;\/table&gt;\r\n&lt;\/body&gt;\r\n&lt;\/html&gt;\r\n-------------------------------------------------------------------<\/pre>\n<blockquote>\n<p>\nJavascript\/dopostback doesn&#8217;t like that colon : in &#8220;theform = document._ctl0:frmPage;&#8221;<\/p>\n<p>My workaround\/solution involved setting the webform Name property = to the webform ID property<br \/>\n(e.g. &#8220;frmPage.Name = frmPage.ID;&#8221;) when the page is initialized.<br \/>\nThis will then output a form tag like:<br \/>\n<code>&lt;form name=\"frmPage\" method=\"post\" action=\"list_emails.aspx\" id=\"frmPage\"&gt;<\/code><\/p>\n<p>\nHere is some code which hopefully illustrates the general idea\/fix:<\/p>\n<p>On the .aspx page you have the form control:<\/p>\n<p><code>&lt;form runat=\"server\" id=\"frmPage\"...&gt;<\/code><\/p>\n<p>&#8230;<\/p>\n<p>Then in the .cs (code behind file) file for the page make sure the form control is declared if not already:<\/p>\n<p><code>protected System.Web.UI.HtmlControls.HtmlForm frmPage;<\/code><\/p>\n<p>&#8230;<\/p>\n<p>Then you set up a method (I called it &#8220;pageInit()&#8221; you can call it whatever) like so:\n<\/p>\n<pre>protected void pageInit()\r\n{\r\nfrmPage.Name = frmPage.ID;\r\n}<\/pre>\n<p>&#8230;<\/p>\n<p>Then you call this method you&#8217;ve just made in an overridden OnInit method for this page<br \/>\n(VS.NET users &#8211; this overridden OnInit is added automatically by VS.NET (I believe) &#8211;<br \/>\nif you&#8217;re NOT using Visual Studio you&#8217;ll have to add your own overridden OnInit if it&#8217;s not already there<br \/>\nand probably take out the &#8220;InitializeComponent&#8221; line shown below as well [that&#8217;s VS.NET related &#8211; for<br \/>\ndesigner support]):\n<\/p>\n<pre>override protected void OnInit(EventArgs e)\r\n{\r\npageInit();\r\nInitializeComponent();\r\nbase.OnInit(e);\r\n}\r\n<\/pre>\n<\/blockquote>\n<p>COMMENTS:<\/p>\n<blockquote>\n<p>\nThis has to be done in every page using a form (with a datagrid, autopostback or linkbutton-type controls at least..).<br \/>\nIt&#8217;s definitely a hack\/workaround, there&#8217;s probably a better solution (like solving this in the template class itself)<br \/>\n&#8211; I just haven&#8217;t had the time to look into it..  Note that I could have also included a<br \/>\n&lt;form runat=&#8221;server&#8221;&#8230;&gt; tag in the page template itself (so that every page is automatically a form)<br \/>\nbut this won&#8217;t work for everybody &#8211; I needed to have other non ASP.NET\/webforms forms (like a search) on pages,<br \/>\nso this solution was not a possibility\n<\/p>\n<\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>This is some technical\/web development stuff&#8230; I am just posting it up here in case it can help anyone who comes across it down the road.<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[43],"tags":[85,53],"class_list":{"0":"post-37","1":"post","2":"type-post","3":"status-publish","4":"format-standard","6":"category-web-stuff","7":"tag-1-1","8":"tag-asp-net","9":"anons"},"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/peSL2o-B","jetpack_sharing_enabled":true,"jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/posts\/37","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/comments?post=37"}],"version-history":[{"count":0,"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/posts\/37\/revisions"}],"wp:attachment":[{"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/media?parent=37"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/categories?post=37"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bdragon.com\/lair\/wp-json\/wp\/v2\/tags?post=37"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}