Showing posts with label postback. Show all posts
Showing posts with label postback. Show all posts

Wednesday, March 28, 2012

Successful validation still blocks postback

Hello,

I have an ASP.NET site that uses validators on a couple pages. On our
staging servers, the site works properly. When I deploy it to the live
server, however, the pages that have validators will not postback. The
validators do appear to be working properly--they show me an error if
the field is empty, and not if it isn't. I saved the generated HTML
from the staging server and the live server, and discovered that there
were a couple differences in the Javascript code related to validation.
I saved the HTML from the live server, and changed code line-by-line,
and eventually wound up with a page that would postback. So the issue
seems to be the generated HTML.

The staging and live servers are both running Win 2k3, IIS 6, .NET
Framework v1.1.4322. The live server does have an older version of .NET
Framework installed. The properties of the site in IIS are set to
process .aspx pages with the v1.1.4322 dll. The WebUIValidation.js file
appears to be in all the right places. The hosting company re-ran
aspnet_regiis.exe, which has cured mysterious ailments in the past.

Has anybody seen anything like this? Any ideas?

ThanksIts probably the bug in ASP.NET 1.1 SP 1. See this thread:
http://forums.asp.net/739537/ShowPost.aspx

-- Peter Blum
www.PeterBlum.com
Email: PLBlum@.PeterBlum.com
Creator of "Professional Validation And More" at
http://www.peterblum.com/vam/home.aspx

<nospamforjoel@.yahoo.com> wrote in message
news:1118757786.746135.236060@.g44g2000cwa.googlegr oups.com...
> Hello,
> I have an ASP.NET site that uses validators on a couple pages. On our
> staging servers, the site works properly. When I deploy it to the live
> server, however, the pages that have validators will not postback. The
> validators do appear to be working properly--they show me an error if
> the field is empty, and not if it isn't. I saved the generated HTML
> from the staging server and the live server, and discovered that there
> were a couple differences in the Javascript code related to validation.
> I saved the HTML from the live server, and changed code line-by-line,
> and eventually wound up with a page that would postback. So the issue
> seems to be the generated HTML.
> The staging and live servers are both running Win 2k3, IIS 6, .NET
> Framework v1.1.4322. The live server does have an older version of .NET
> Framework installed. The properties of the site in IIS are set to
> process .aspx pages with the v1.1.4322 dll. The WebUIValidation.js file
> appears to be in all the right places. The hosting company re-ran
> aspnet_regiis.exe, which has cured mysterious ailments in the past.
> Has anybody seen anything like this? Any ideas?
> Thanks

Thursday, March 22, 2012

Suppress Postback on ImageButton

Is there a straightforward way to suppress the postback on an imagebutton? I want it to only fire the client onclick event.

Thanks!

If you return false from your OnClientClick event, then the postback will not be invoked.

Thanks for the response. Hmmm...didn't seem to work in this example. Did I miss something?
==============================

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="ImageButton1" runat="server" Height="20px" Width="20px"
Style="z-index: 101; left: 180px; position: absolute; top: 128px"
OnClientClick="javascript:ImageClick(this)"/>
</div>
</form>
<script>
function ImageClick(varObj)
{
alert(varObj.tagName)
return false
}
</script>
</body>
</html>

==============================


Thanks for the response. Hmmm...didn't seem to work in this example. Did I miss something?
==============================

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ImageButton ID="ImageButton1" runat="server" Height="20px" Width="20px"
Style="z-index: 101; left: 180px; position: absolute; top: 128px"
OnClientClick="javascript:ImageClick(this)"/>
</div>
</form>
<script>
function ImageClick(varObj)
{
alert(varObj.tagName)
return (false)
}
</script>
</body>
</html>

==============================


Just returnfalsefrom your ImageClick() javascript function, or do something like:

OnClientClick="javascript:ImageClick(this); return false;"/>
Got it. Works great. Thanks!

Suppress postback added to history WITHOUT smartnavigation

I remember hearing that you could use javascript document.location.href to p
revent a link from being added to the browser history.
Has anyone found a way to implement this behaviour for page postbacks withou
t using smartnavigation?
SmartNavigation causes me too many javascript headaches. Anyone know of a ba
se page class (or something) that would accomplish that feature of smartnavi
gation?
Or perhaps you happen to be using CoolMenus and know how to fix the page so
it works with SmartNavigation :) ?
Thanks for any help.
From: Mark Petersen
Posted by a user from .NET 247 (http://www.dotnet247.com/)
<Id>emWuhAFdl0mktgkkLUxWpQ==</Id>Hello,
> Has anyone found a way to implement this behaviour for page postbacks without usin
g smartnavigation?
This article deals with that issue:
Maintaining Scroll Position on Postback (without SmartNavigation)
http://aspnet.4guysfromrolla.com/articles/111704-1.aspx
"Mark Petersen via .NET 247" wrote:

> I remember hearing that you could use javascript document.location.href to
prevent a link from being added to the browser history.
> Has anyone found a way to implement this behaviour for page postbacks with
out using smartnavigation?
> SmartNavigation causes me too many javascript headaches. Anyone know of a
base page class (or something) that would accomplish that feature of smartna
vigation?
> Or perhaps you happen to be using CoolMenus and know how to fix the page s
o it works with SmartNavigation :) ?
> Thanks for any help.
> --
> From: Mark Petersen
> --
> Posted by a user from .NET 247 (http://www.dotnet247.com/)
> <Id>emWuhAFdl0mktgkkLUxWpQ==</Id>
>