 |
| ASP.NET 2.0 Professional If you are an experienced ASP.NET programmer, this is the forum for your 2.0 questions. Please also see the Visual Web Developer 2005 forum. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the ASP.NET 2.0 Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 27th, 2006, 10:26 AM
|
|
Friend of Wrox
|
|
Join Date: Apr 2005
Posts: 190
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar:
Well ! Its been over two months since getting your last word on this topic. I had to attend to fixing an old app that was high priority but more importantly I think I have found the answer to my basic question. To re-iterate: we were tackling the issue of validation client side vs. server side, and you stated that server side is the preferred.
I have discovered Ajax/Atlas and am going thru "Foundations of Atlas" by Laurence Moroney.
Basically, Atlas will allow me to do the bulk of the validation (and any other UI tier adjustment) on the client side without ever having to do a round trip to the server. Thus, I can do all the validations, types, presence, range, etc. before the data ever leaves the client.
To be sure tho in view of your last comments, I will preserve the serverside validations and some other processing on the server to insure that nothing bad happens to the data while being sent to the server.
I can see that Ajax/Atlas is going to **revolutionize** website apps in that with a bit more development, the days of needing to send an entire page to the server and back to do some simple thing are going to end. In its place much of the server side functionality can be done client side beforehand. And most importantly, only data that changes needs to be sent to the server -- a much smaller amount resulting in substantially faster turn around time.
Regards,
VV
|
|

September 27th, 2006, 01:13 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Right, so you *do* have that mystical month that falls between August and September. Hmmmm..... ;)
I never said server side is preferred. I said server side is essential / critical, and you should consider client side validation as well, mainly as a gesture to your users. If you like your users, and you want them to like you, and protect your system at the same time, you should implement both.
Atlas (or should we say the Microsoft AJAX Library now) does indeed throw new and exciting possibilities in the mix. It allows you to have server side validation, with a client side look and feel. This opens up possibilities to much more advanced server side validations (database look ups, web services, whatever) and still present a snappy user interface.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

December 4th, 2006, 02:40 PM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Imar
I have a similar but different issue.I am using confirmation on exit(of any kind) window.onbeforeunload.But this gets fired even on the asp:button which is posting some data to the DB through SP.Is there a way that i can bypass this onbeforeunload event when i click asp:button.Here is what i am trying and also the error i am getting.
**************
<html>
<head>
<script language="JavaScript">
var needToConfirm = true;
window.onbeforeunload = confirmExit;
function confirmExit()
{
if (needToConfirm)
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
</script>
</head>
<body>
<form>
<asp:button Runat="server" Text="Save" onclick="needToConfirm = false;" ></asp:Button>
</form>
</body>
</html>
**************
The error i get is
CS1026: ) expected
****************
Thanks
Kamal
|
|

December 4th, 2006, 05:27 PM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
onclick is a *server side* event that tries to run C# code.
I think you're looking for OnClientClick instead....
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|

December 4th, 2006, 05:40 PM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar,
I tried onClientClick as well.But nothing happens.The onbeforeunload event is still fired onclick.
Thanks for help
Kamal
|
|

December 4th, 2006, 06:10 PM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar
This is my HTML .The web page is for testing purpose only so it just has one asp:button.
**********
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="JavaScript">
var needToConfirm = true;
window.onbeforeunload = confirmExit;
document.all["Button1"].onclick ="needToConfirm = false;" ;
function confirmExit()
{
if (needToConfirm)
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" runat="server"
Text="Button" ></asp:Button>
</form>
</body>
</HTML>
************
The actual web Page has lots of other controls and data in Data Grid that when button is clicked is posted to the Data Base via Stored Procedure.That is where i want to bypass onbeforeunload event.
I hope i make sense.
Thanks
Kamal
|
|

December 5th, 2006, 09:21 AM
|
|
Authorized User
|
|
Join Date: Dec 2006
Posts: 48
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Imar,
I am sorry.I misunderstood you.Here is how HTMl looks like
**************
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"content="http://schemas.microsoft.com/intellisense/ie5">
<script language="JavaScript">
var needToConfirm = true;
window.onbeforeunload = confirmExit;
document.all["Button1"].onclick ="needToConfirm = false;" ;
function confirmExit()
{
if (needToConfirm)
return "You have attempted to leave this page. If you have made any changes to the fields without clicking the Save button, your changes will be lost. Are you sure you want to exit this page?";
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WebForm1.aspx" id="Form1">
<input type="hidden" name="__VIEWSTATE" value="dDw5NjU1MTU1Ozs+ZMe/YzNJ8mHHmvf5Yc5QSvBQljk=" />
<input type="submit" name="Button1" value="Button" id="Button1" style="Z-INDEX: 101; LEFT: 8px; POSITION: absolute; TOP: 8px" />
</form>
</body>
</HTML>
****************************
And the footer bar on window always tell me that its done with error on page.I hope this is what you want.
Thanks
Kamal
|
|

December 5th, 2006, 09:32 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
I don't see the results from OnClientClick in the final HTML, nor in the original ASPX. You need something like this:
<asp:Button id="Button1" OnClientClick="needToConfirm=false; return true;" .... />
Does that work?
Imar
---------------------------------------
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Everyone is unique, except for me.
Author of ASP.NET 2.0 Instant Results and Beginning Dreamweaver MX / MX 2004
Want to be my colleague? Then check out this post.
|
|
 |