ASP.NET 1.0 To 1.1 Upgrade Issues
This is some technical/web development stuff... I am just posting it up here in case it can help anyone who comes across it down the road.
I 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 "before".
When I upgraded my .NET version from 1.0 to 1.1 I came across some issues that I hadn't/haven't seen mentioned anywhere that I could find... so just in case these can help somebody, I am putting some rambing type of descriptions here.
ASP.NET 1.0 -> ASP.NET 1.1 Upgrade Issues (and fixes): ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ERROR OR PROBLEM:
Bizarre(?) runtime error -- Parser Error Message: Type 'System.Web.HttpBrowserCapabilities' does not inherit from 'System.Web.Mobile.MobileCapabilities'.SOLUTION:
Had to uncomment/remove the browsercaps "result" element in web.config fileCOMMENTS:
Doesn't seem to have affected/broken anything else (so far?)
<browserCaps>
<!-- result type="System.Web.HttpBrowserCapabilities" / -->
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ERROR OR PROBLEM:
Paging on datagrids no longer worked, though it worked before, (this also might affect "linkbuttons"? I don'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 "template" system whereby my webforms were using a "template" class derived from system.web.ui.page and the javascript "dopostback" code that is generated to post the form to the server... I had run into this issue before with ASP.NET 1.0 when using an "autopostback" dropdownlist which wouldn't work automatically in Mozilla until I also implemented the solution below...SOLUTION:
The dopostback javascript "breaks" due to the fact that a control name (like "ctl0:" or "ctl0_") 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:
-------------------------------------------------------------------
<html>
<head>
<body>
<form name="_ctl0:frmPage" method="post" action="list_emails.aspx" id="_ctl0_frmPage">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["_ctl0:frmPage"];
}
else {
//this is the line causing the problem (in non-netscape browsers at least):
theform = document._ctl0:frmPage;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
<br clear="all" />
<table>
<tr>
<td><span>1</span>
<a href="javascript:__doPostBack('_ctl0$dgData$_ctl1$_ctl1','')">2</a>
<a href="javascript:__doPostBack('_ctl0$dgData$_ctl1$_ctl2','')">3</a>
<a href="javascript:__doPostBack('_ctl0$dgData$_ctl1$_ctl10','')">...</a></td>
</tr>
</table>
</body>
</html>
-------------------------------------------------------------------
Javascript/dopostback doesn't like that colon : in "theform = document._ctl0:frmPage;"COMMENTS:
My workaround/solution involved setting the webform Name property = to the webform ID property (e.g. "frmPage.Name = frmPage.ID;") when the page is initialized. This will then output a form tag like:
<form name="frmPage" method="post" action="list_emails.aspx" id="frmPage">
Here is some code which hopefully illustrates the general idea/fix:
On the .aspx page you have the form control:
<form runat="server" id="frmPage"...>
...
Then in the .cs (code behind file) file for the page make sure the form control is declared if not already:
protected System.Web.UI.HtmlControls.HtmlForm frmPage;
...
Then you set up a method (I called it "pageInit()" you can call it whatever) like so:
protected void pageInit() { frmPage.Name = frmPage.ID; }
...
Then you call this method you've just made in an overridden OnInit method for this page (VS.NET users - this overridden OnInit is added automatically by VS.NET (I believe) - if you're NOT using Visual Studio you'll have to add your own overridden OnInit if it's not already there and probably take out the "InitializeComponent" line shown below as well [that's VS.NET related - for designer support]):
override protected void OnInit(EventArgs e) { pageInit(); InitializeComponent(); base.OnInit(e); }
This has to be done in every page using a form (with a datagrid, autopostback or linkbutton-type controls at least..). It's definitely a hack/workaround, there's probably a better solution (like solving this in the template class itself) - I just haven't had the time to look into it.. Note that I could have also included a <form runat="server"...> tag in the page template itself (so that every page is automatically a form) but this won't work for everybody - I needed to have other non ASP.NET/webforms forms (like a search) on pages, so this solution was not a possibility

