Dino Rex - ReDoXiN

Dino Rex's BLOG

Making migrated .NET 3.5 web apps from 1.2 to be truly supported by multi-browsers

clock November 14, 2008 18:21 by author Dino Rex
when you migrate the web applications from .NET 1.2 to version 3.5 you will discover all validator controls are not functioning at all in non-IE environments (that's the same for all web applications developed in .NET 1.2 )

I have used one whole night to google, and found out the following workaround

source : http://forums.asp.net/t/1283702.aspx

Put it simply, in 'Web.Config', delete the following line: -

<xhtmlConformance mode="Legacy"/>

quote from the original source: -

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

set in your web.config, then client-side validation is disabled in firefox.

To see why, we have to jump down into the validation framework that ASP.Net sends to the web browser. The actual Javascript validation function looks like:

function ValidatorValidate(val) {

val.isvalid = true;

if (val.enabled != false) {

if (typeof(val.evaluationfunction) == "function") {

val.isvalid = val.evaluationfunction(val);

}

}

ValidatorUpdateDisplay(val);

}

Using Venkman, I was able to see that val.evaluationfunction wasn't a function at all, therefore the page wasn't getting validated because of this. A bit more searching found that this evaluationfunction is an expando attribute. In ASP.Net v1, this expando is an IE-only HTML expando, defined directly in the HTML markup. In ASP.Net v2, this is a Javascript expando attribute, defined on the DOM via Javascript, and therefore compatible with both IE and Firefox.

For example, the RequiredFieldValidator calls RegisterExpandoAttribute. You can call this method yourself like:


Page.ClientScript.RegisterExpandoAttribute(TextBox1.ClientID, "value", TextBox1.Text);

This produces a block of Javascript just before the closing tag like:


<script type="text/javascript">

<!--

var TextBox1 = document.all ? document.all["TextBox1"] : document.getElementById("TextBox1");

TextBox1.value = "";

// -->

</script>

where "value" has become the new expando attribute. In the case of the RequiredFieldValidator, the expando name is" evaluationfunction" and it is added to the representing the control at runtime.


It turned out that this block of Javascript wasn't being sent to Firefox in my situation, and I didn't know why. Instead, the evaluationfunction expando attribute was being rendered directly on the element in HTML.

So after good deal of decompilation using Reflector, and debugging using Reflection Invokeing of private methods, I discovered the problem was that RegisterExpandoAttribute checks the XHTML Rendering Mode prior to generating the Javascript and if that rendering mode is set to Legacy, then the expando is rendered directly onto the element and no Javascript code is rendered. The result of this is to prevent Firefox from performing client-side validation when Legacy XHTML mode is set.


I have no idea why the ASP.Net team chose to do this for validation. Perhaps the Legacy XHTML setting should have been called "ASPNetv1Conformance" because that's actually what it does. The docs for Legacy mode state:


"Reverts a number of rendering changes made for conformance to the v1.1 rendering behavior."

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


[C#] Loading and reading the Microsoft Excel file contents using C#

clock May 24, 2007 18:11 by author Dino Rex
If you are not lazy, you can search the following CodeProject via Google within seconds: -
http://www.codeproject.com/useritems/Excel_Application_in_C_.asp
This mechanism can be used, but it has some considerations: for your deployment, you need to apply the Office component (which is using Microsoft.Office..blah blah blah..Excel, instead of the mentioned using Excel; ~!) to read the cells, that means, the deployment machine needs to purchase an extra Office licence for the deployment - most of the small businesses are reluctant to do so.. moreover, since this Office Object is version dependent, when the developer has an office version different from that in the client site, a nightmare .. XD
Therefore, you must ask: How can I accomplish that goal then?..
The answer is: SIMPLY USE StreamReader to directly read the file LINE BY LINE!..
If you don't trust me, you can try it yourself by setting similar Console App and you 'll get amazing results~!
This workaround is valid even for Visual Studio 2003, and the behind scene mechanism of that fussy StreamReader Object is a mystery to me..

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


[browser technique] print a web page free from print dialog box

clock April 18, 2007 17:58 by author Dino Rex
Thousands of materials in web are talking about this topic, but I found none of them works..
So I just trying that all by myself..
just copy and paste the following html code into your web page and test, then you can get a fancy result..
(PS. Please don't ask me why javascript counterpart cannot hide the print dialog box, since I also don't know.. Orz)
* I guess maybe that's M$ strategy to force you to write stuff on VBScript instead of Javascript..

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


About me

Just a corner for me - a slow rex living in a small suburb in Sydney, Australia

Powered by weRead

Calendar

<<  November 2009  >>
MoTuWeThFrSaSu
2627282930311
2345678
9101112131415
16171819202122
23242526272829
30123456

View posts in large calendar

RecentComments

None

Tag cloud

    Page List

      Sign in