Quantcast
Channel: AjaxControlToolkit Work Item Rss Feed
Viewing all articles
Browse latest Browse all 4356

Commented Issue: ModalPopupExtender and ValidationSummary not working on Page_Load [27024]

$
0
0
I have a ModalPopupExtender (mpeAddEdit) that shows on page load. In the ModalPopupExtender there is a ValidationSummary Control (vsDutyLog). If the validationsummary control is present or enabled, then when the call to how the ModalPopupExtender in Page_Load (mpeAddEdit.show() ) , generates an error in the javascript: 'Microsoft JScript runtime error: Object expected' at the line(s) in the javascript reading:

document.getElementById('cphBody_vsDutyLog').dispose = function() {
Array.remove(Page_ValidationSummaries, document.getElementById('cphBody_vsDutyLog'));
}
(function() {var fn = function() {Sys.Extended.UI.ModalPopupBehavior.invokeViaServer('cphBody_mpeAddEdit', true); Sys.Application.remove_load(fn);};Sys.Application.add_load(fn);})();

If the ValidationSummary control is not enabled, or is commented out, then there are no errors generated. Also, if the ModalPopupExtender is shown at any other time than page load, there are no errors (i.e. shown via clicking a link).

It seems like this was somewhat of an issue once before and that the issue related to incorrectly generated javascript (see http://forums.asp.net/t/1175339.aspx/1). The work around here defined seems to alleviate the issue, but then the ValidationSummary is not usable as it is diabled. (See also http://ajaxcontroltoolkit.codeplex.com/workitem/12835?ProjectName=ajaxcontroltoolkit for more information about a suitable interim workaround).

For me this is a high priority issue as it directly affects work I'm currently doing.
Comments: You can also work around this issue by creating a custom server control that derives from the ValidationSummary control. Then, instead of using ASP.NET's ValidationSummary control, you'd use your custom one wherever you experience this issue. Here's the code for the server control (in this example, the server control lives in its own project/assembly named "MyServerControls"): namespace MyNamespace { [ToolboxData("")] public class AjaxValidationSummary : ValidationSummary { protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); ScriptManager.RegisterStartupScript(this.Page, this.Page.GetType(), this.ClientID, ";", true); } } } If you want to use the control on multiple pages in your site, add the following to your site's web.config: <configuration> <system.web> ... <pages ...> <controls> <add assembly="MyServerControls" namespace="MyNamespace" tagPrefix="MyControls"/> </controls> </pages> ... </system.web> Then, in your markup, use the <MyControls:AjaxValidationSummary ... /> control wherever you're running into this issue.

Viewing all articles
Browse latest Browse all 4356

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>