Home All Groups Group Topic Archive Search About
Author
12 Jan 2007 10:49 AM
marss
Hi all,
With the advent of Service Pack 1 for Visual Studio 2005 we at last get
a possibility
to convert our old ASP.Net 1.1 web application to ASP.Net 2.0. We
converted it. And we were unpleasantly impressed. There are many just
praises about reduced ViewState but what about another controls?

For example:

LinkButton that causes validation renders as hyperlink with the script
in href attribute.
ASP.Net 1.1 (117 b)
javascript:{if (typeof(Page_ClientValidate) != 'function' ||
Page_ClientValidate()) __doPostBack('LinkButton1','')}
ASP.Net 2.0 (156 b)
javascript:WebForm_DoPostBackWithOptions(new
WebForm_PostBackOptions("LinkButton1", "", true,
"", "", false, true))

You may say, that difference in 39 bytes is not so much. But with a
little rewriting of the source file it would be looked like
javascript:WebForm_DoPostBackWithOptions('LinkButton1','',true,'','',false,true)
and difference become more essential. It's looks like nobody in VS2005
developer's team tries to optimize code.

I want to particularly point to validators:
ASP.Net 1.1 (241 b)
<span id="RequiredFieldValidator1" controltovalidate="TextBox1"
errormessage="Value required" display="Dynamic"
evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
initialvalue="" style="color:Red;display:none;">Value required</span>
ASP.Net 2.0 (520 b)
<span id="RequiredFieldValidator1"
style="color:Red;display:none;">Value required</span>
+
script in the body of a page:
var RequiredFieldValidator1 = document.all ?
document.all["RequiredFieldValidator1"] :
document.getElementById("RequiredFieldValidator1");
RequiredFieldValidator1.controltovalidate = "TextBox1";
RequiredFieldValidator1.errormessage = "Value required";
RequiredFieldValidator1.display = "Dynamic";
RequiredFieldValidator1.evaluationfunction =
"RequiredFieldValidatorEvaluateIsValid";
RequiredFieldValidator1.initialvalue = "";

Four validators on a page -  1kB of the additional traffic. Pretty
good, isn't it?
Or I am wrong and in the most countries internet has already changed to
intranet and page size is unimportant?

Would like to hear expert's opinions.

Sorry for my English.

P.S. Source for all examples is empty page + 3 controls:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:LinkButton ID="LinkButton1"
runat="server">LinkButton</asp:LinkButton>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="TextBox1"
            Display="Dynamic" ErrorMessage="Value
required"></asp:RequiredFieldValidator>

Author
12 Jan 2007 11:53 AM
Nate
You bring up a good point.  The validation controls were designed to be
generic, cross-browswer compliant, re-usable with all server input controls,
and provide a common way to perform validation (without everyone making their
own custom implementations).  Your alternative is to create custom
client-side validation javascript that is browser compliant that is fires
when the form submits, and then also create a server-side validation routine
to catch any form submittals where the user has js disabled (or an error
occurred in your js which let the form submit w/o validating) or if the user
is malicious and spoofed form values.

I really wouldn't get all that worried about 1k, for all of that
out-of-the-box functionality... Its a trade-off.  What you can do to
compensate however is to optimize the HTML that you are creating elsewhere: 
remove excess white-space, move inline CSS styles into CSS classes on a
linked CSS file, shrink CSS class names, shift HTML attributes to CSS which
are in a separate linked CSS file (when possible), optimize images (sometimes
jpegs are smaller than gifs and vice versa), and whatever else you can think
of.

Show quoteHide quote
"marss" wrote:

> Hi all,
> With the advent of Service Pack 1 for Visual Studio 2005 we at last get
> a possibility
> to convert our old ASP.Net 1.1 web application to ASP.Net 2.0. We
> converted it. And we were unpleasantly impressed. There are many just
> praises about reduced ViewState but what about another controls?
>
> For example:
>
> LinkButton that causes validation renders as hyperlink with the script
> in href attribute.
> ASP.Net 1.1 (117 b)
> javascript:{if (typeof(Page_ClientValidate) != 'function' ||
> Page_ClientValidate()) __doPostBack('LinkButton1','')}
> ASP.Net 2.0 (156 b)
> javascript:WebForm_DoPostBackWithOptions(new
> WebForm_PostBackOptions("LinkButton1", "", true,
> "", "", false, true))
>
> You may say, that difference in 39 bytes is not so much. But with a
> little rewriting of the source file it would be looked like
> javascript:WebForm_DoPostBackWithOptions('LinkButton1','',true,'','',false,true)
> and difference become more essential. It's looks like nobody in VS2005
> developer's team tries to optimize code.
>
> I want to particularly point to validators:
> ASP.Net 1.1 (241 b)
> <span id="RequiredFieldValidator1" controltovalidate="TextBox1"
> errormessage="Value required" display="Dynamic"
> evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
> initialvalue="" style="color:Red;display:none;">Value required</span>
> ASP.Net 2.0 (520 b)
> <span id="RequiredFieldValidator1"
> style="color:Red;display:none;">Value required</span>
> +
> script in the body of a page:
> var RequiredFieldValidator1 = document.all ?
> document.all["RequiredFieldValidator1"] :
> document.getElementById("RequiredFieldValidator1");
> RequiredFieldValidator1.controltovalidate = "TextBox1";
> RequiredFieldValidator1.errormessage = "Value required";
> RequiredFieldValidator1.display = "Dynamic";
> RequiredFieldValidator1.evaluationfunction =
> "RequiredFieldValidatorEvaluateIsValid";
> RequiredFieldValidator1.initialvalue = "";
>
> Four validators on a page -  1kB of the additional traffic. Pretty
> good, isn't it?
> Or I am wrong and in the most countries internet has already changed to
> intranet and page size is unimportant?
>
> Would like to hear expert's opinions.
>
> Sorry for my English.
>
> P.S. Source for all examples is empty page + 3 controls:
> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
> <asp:LinkButton ID="LinkButton1"
> runat="server">LinkButton</asp:LinkButton>
> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
> ControlToValidate="TextBox1"
>             Display="Dynamic" ErrorMessage="Value
> required"></asp:RequiredFieldValidator>
>
>
Author
12 Jan 2007 1:19 PM
marss
Thanks for anwser, Nate

I have nothing against cross-browswer compliant script, I do not
understand whether it is necessary put all code in the page body
instead of separate file.

As for custom validators: either it supports existing validation schema
(and has no any advantages) or implements its own (but it causes
rewriting all controls that use old schema: Button, LinkButton, etc).
Author
12 Jan 2007 9:16 PM
bruce barker
ms decided xhtml conformance was desirable. this means no custom
attributes are allowed, so they had to be moved to javascript objects
and quotes must be quoted.


-- bruce (sqlwork.com)

marss wrote:
Show quoteHide quote
> Hi all,
> With the advent of Service Pack 1 for Visual Studio 2005 we at last get
> a possibility
> to convert our old ASP.Net 1.1 web application to ASP.Net 2.0. We
> converted it. And we were unpleasantly impressed. There are many just
> praises about reduced ViewState but what about another controls?
>
> For example:
>
> LinkButton that causes validation renders as hyperlink with the script
> in href attribute.
> ASP.Net 1.1 (117 b)
> javascript:{if (typeof(Page_ClientValidate) != 'function' ||
> Page_ClientValidate()) __doPostBack('LinkButton1','')}
> ASP.Net 2.0 (156 b)
> javascript:WebForm_DoPostBackWithOptions(new
> WebForm_PostBackOptions(&quot;LinkButton1&quot;, &quot;&quot;, true,
> &quot;&quot;, &quot;&quot;, false, true))
>
> You may say, that difference in 39 bytes is not so much. But with a
> little rewriting of the source file it would be looked like
> javascript:WebForm_DoPostBackWithOptions('LinkButton1','',true,'','',false,true)
> and difference become more essential. It's looks like nobody in VS2005
> developer's team tries to optimize code.
>
> I want to particularly point to validators:
> ASP.Net 1.1 (241 b)
> <span id="RequiredFieldValidator1" controltovalidate="TextBox1"
> errormessage="Value required" display="Dynamic"
> evaluationfunction="RequiredFieldValidatorEvaluateIsValid"
> initialvalue="" style="color:Red;display:none;">Value required</span>
> ASP.Net 2.0 (520 b)
> <span id="RequiredFieldValidator1"
> style="color:Red;display:none;">Value required</span>
> +
> script in the body of a page:
> var RequiredFieldValidator1 = document.all ?
> document.all["RequiredFieldValidator1"] :
> document.getElementById("RequiredFieldValidator1");
> RequiredFieldValidator1.controltovalidate = "TextBox1";
> RequiredFieldValidator1.errormessage = "Value required";
> RequiredFieldValidator1.display = "Dynamic";
> RequiredFieldValidator1.evaluationfunction =
> "RequiredFieldValidatorEvaluateIsValid";
> RequiredFieldValidator1.initialvalue = "";
>
> Four validators on a page -  1kB of the additional traffic. Pretty
> good, isn't it?
> Or I am wrong and in the most countries internet has already changed to
> intranet and page size is unimportant?
>
> Would like to hear expert's opinions.
>
> Sorry for my English.
>
> P.S. Source for all examples is empty page + 3 controls:
> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
> <asp:LinkButton ID="LinkButton1"
> runat="server">LinkButton</asp:LinkButton>
> <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
> ControlToValidate="TextBox1"
>             Display="Dynamic" ErrorMessage="Value
> required"></asp:RequiredFieldValidator>
>
Author
15 Jan 2007 7:53 AM
marss
bruce barker wrote:
> ms decided xhtml conformance was desirable. this means no custom
> attributes are allowed, so they had to be moved to javascript objects
> and quotes must be quoted.
>
>
> -- bruce (sqlwork.com)

Hello, Bruce,
I completely disagree with you about impossibility of custom attributes
use in xhtml compliant pages, but anyway, thanks for your opinion.