I have 3 image buttons (flag gifs used to change the language of the page) with CausesValidation=False . They work fine EXCEPT if a form has any validation controls then image buttons do not cause a postback. Can anyone please advise?
As you probably know, CausesValidation = false tells the control to submit without validation. I have not heard of any bugs in Microsoft's ImageButtons regarding this problem. So I'm wondering if there is something changing CausesValidation to true programmatically?
Please post the following: 1. The ASP.NET text for one of the ImageButtons. 2. Any code behind program code associated with that ImageButton. 3. Use ViewSource and search for the ID of the ImageButton. I want to see the HTML tags for that Image button. 4.
Any <script> tags near the bottom.
--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
Thanks, here it is, as I mentioned works fine except on pages with validation controls (shown here) 1. The ASP.NET text for one of the ImageButtons. 2. Any code behind program code associated with that ImageButton. Public Sub btnLanguageEn_Click(ByVal o As
Object, ByVal e As ImageClickEventArgs) Handles btnLanguageEn.Click AppSettings.SetLanguageAndCultureFromParameter("en") End Sub 3. HTML rendered <input type="image" name="btnLanguageEn" id="btnLanguageEn" src="images/common/flags/en.gif" alt="English" border="0"
style="width:18px;" /> 4. Script Tags near the bottom
<script language="javascript">
<!--
var Page_ValidationSummaries = new Array(document.all["_ctl2__ctl2_MyValSum"]);
var Page_Validators = new Array(document.all["_ctl2__ctl2_ReqFldValEmail"], document.all["_ctl2__ctl2_RegExpValEmail"], document.all["_ctl2__ctl2_ReqFldValName"], document.all["_ctl2__ctl2_ReqFldValSubject"], document.all["_ctl2__ctl2_ReqFldValMessage"]);
// -->
</script>
<script language="javascript">
<!--
var Page_ValidationActive = false;
if (typeof(clientInformation) != "undefined" && clientInformation.appName.indexOf("Explorer") != -1) {
if (typeof(Page_ValidationVer) == "undefined")
alert("Unable to find script library '/aspnet_client/system_web/1_1_4322/WebUIValidation.js'. Try placing this file manually, or reinstall by running 'aspnet_regiis -c'.");
else if (Page_ValidationVer != "125")
alert("This page uses an incorrect version of WebUIValidation.js. The page expects version 125. The script library is " + Page_ValidationVer + ".");
else
ValidatorOnLoad();
}
function ValidatorOnSubmit() {
if (Page_ValidationActive) {
return ValidatorCommonOnSubmit();
}
return true;
}
// -->
</script>
I did a test and loaded the control into another page and the HTML rendered with the _ctl0_ id in place - as you can see it didn't on my pther attempt, so this has somthing to do with the way I am loading the control in regard to my page design (see below)
where the image button control was in the aspx...ummm...any ideas... Thanks in advance.
<input type="image" name="_ctl0:btnLanguageEn" id="_ctl0_btnLanguageEn" src="images/common/flags/en.gif" alt="default_Language_En" border="0" style="width:18px;" />
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
Me.Controls.AddAt(0, LoadControl("common\page\Header.ascx"))
MyBase.OnInit(e)
Me.Controls.Add(LoadControl("common\page\Footer.ascx"))
end sub
I'm confused. When you showed me this: <input type="image" name="btnLanguageEn" id="btnLanguageEn" src="images/common/flags/en.gif" alt="English" border="0" style="width:18px;" /> it lacked the statement onclick="if (typeof(Page_ClientValidate) == 'function')
Page_ClientValidate();" That statement runs submit validation. Later, the
--- Peter Blum
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
The problem was with ms hotfix m818803 caused the difference between 1.1.4322.573 and .903 (I unistalled the hotfix and it works fine. I have reported the 'dare i call it a bug' to microsoft) it is to lengthly to go into here but the problem appeared because
I had .903 and my isp had .573 - my advice is do not install this hotfix or if anyone does make sure the production server and all development pcs have it (or don't have it) as (by design or otherwise) there is different behavior (and js rendering) between
.903 and .573 FYI, I was told that (something like) the .903 hotfix will make it into the upcoming sp1...which hopefully will not break anything...but again...it took 6 months in the real world to show itself but .573 vs .903 are different, I think they both
basically work but - as I found - it is possible to write code that works on .903 and not .573 see http://support.microsoft.com/default.aspx?scid=kb;en-us;818803 for details
donaldn
Member
392 Points
82 Posts
image buttons do not cause postback if form has validators
Feb 19, 2004 04:48 PM|LINK
PLBlum
All-Star
30409 Points
5347 Posts
MVP
Re: image buttons do not cause postback if form has validators
Feb 19, 2004 09:40 PM|LINK
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
donaldn
Member
392 Points
82 Posts
Re: image buttons do not cause postback if form has validators
Feb 19, 2004 11:42 PM|LINK
<script language="javascript"> <!-- var Page_ValidationSummaries = new Array(document.all["_ctl2__ctl2_MyValSum"]); var Page_Validators = new Array(document.all["_ctl2__ctl2_ReqFldValEmail"], document.all["_ctl2__ctl2_RegExpValEmail"], document.all["_ctl2__ctl2_ReqFldValName"], document.all["_ctl2__ctl2_ReqFldValSubject"], document.all["_ctl2__ctl2_ReqFldValMessage"]); // --> </script> <script language="javascript"> <!-- var Page_ValidationActive = false; if (typeof(clientInformation) != "undefined" && clientInformation.appName.indexOf("Explorer") != -1) { if (typeof(Page_ValidationVer) == "undefined") alert("Unable to find script library '/aspnet_client/system_web/1_1_4322/WebUIValidation.js'. Try placing this file manually, or reinstall by running 'aspnet_regiis -c'."); else if (Page_ValidationVer != "125") alert("This page uses an incorrect version of WebUIValidation.js. The page expects version 125. The script library is " + Page_ValidationVer + "."); else ValidatorOnLoad(); } function ValidatorOnSubmit() { if (Page_ValidationActive) { return ValidatorCommonOnSubmit(); } return true; } // --> </script>donaldn
Member
392 Points
82 Posts
Re: image buttons do not cause postback if form has validators
Feb 19, 2004 11:54 PM|LINK
<input type="image" name="_ctl0:btnLanguageEn" id="_ctl0_btnLanguageEn" src="images/common/flags/en.gif" alt="default_Language_En" border="0" style="width:18px;" /> Protected Overrides Sub OnInit(ByVal e As System.EventArgs) Me.Controls.AddAt(0, LoadControl("common\page\Header.ascx")) MyBase.OnInit(e) Me.Controls.Add(LoadControl("common\page\Footer.ascx")) end subPLBlum
All-Star
30409 Points
5347 Posts
MVP
Re: image buttons do not cause postback if form has validators
Feb 20, 2004 07:22 PM|LINK
Creator of Peter's Data Entry Suite (formerly Professional Validation And More and Peter's Date Package) and Peter's Polling Package
www.PeterBlum.com
donaldn
Member
392 Points
82 Posts
Re: image buttons do not cause postback if form has validators
Feb 21, 2004 09:35 PM|LINK