In trying to troubleshoot my issues with the migration I noted that for the sample ModalPopUp example with the toolkit automatically populates the DynamicServicePath
From the toolkit example (Beta release )
Sys.Application.add_init(function() {
$create(AjaxControlToolkit.ModalPopupBehavior, {"BackgroundCssClass":"modalBackground","CancelControlID":"ctl00_ContentPlaceHolder1_CancelButton","DropShadow":true,"DynamicServicePath":"/test/ModalPopup/ModalPopup.aspx","id":"ctl00_ContentPlaceHolder1_ModalPopupExtender","OkControlID":"ctl00_ContentPlaceHolder1_OkButton","OnOkScript":"onOk()","PopupControlID":"ctl00_ContentPlaceHolder1_Panel1"}, null, null, $get('ctl00_ContentPlaceHolder1_LinkButton1'));
});
In my application - all of my urls are dynamically served... and so for instance for this page url: /localhost/SitesEasyTest/admin/EditNamedPages/default.aspx
The following gets generated:
Sys.Application.add_init(function() {
$create(AjaxControlToolkit.ModalPopupBehavior, {"BackgroundCssClass":"modalBackground","DropShadow":true,"DynamicServicePath":"/SitesEasyTest/default.aspx","id":"PopUp","PopupControlID":"ctl00_ctl00_ctl00_PanelModal"}, null, null, $get('ctl00_ctl00_ctl00_Target'));
It is not grabbing the actual url that it should. In the ModalPopUp example and in my own code the DynamicServicePath is not declared it is added by the toolkit at runtime...
I attempted to correct the value via code behind:
MyPopUp = (ModalPopupExtender)GetOptionalControl(skin,"MyPopUp");
MyPopUp.DynamicServicePath = (CommunityGlobals.CalculatePath("Default.aspx")); // properly generates relative path url to the dynamic page
However, the following error is displayed when compiled and tested in a browser:
DynamicControlID must be set
Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details:System.ArgumentException: DynamicControlID must be set
[ArgumentException: DynamicControlID must be set] AjaxControlToolkit.DynamicPopulateExtenderControlBase.EnsureValid() +372 AjaxControlToolkit.ExtenderControlBase.GetScriptDescriptors(Control targetControl) +98 Microsoft.Web.UI.ExtenderControl.Microsoft.Web.UI.IExtenderControl.GetScriptDescriptors(Control targetControl) +7 Microsoft.Web.UI.ScriptControlManager.RegisterScriptsForExtenderControls() +187 Microsoft.Web.UI.ScriptManager.OnPreRender(EventArgs e) +402 System.Web.UI.Control.PreRenderRecursiveInternal() +77 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Control.PreRenderRecursiveInternal() +161 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1360
In either case - the script generated does not generate a DynamicControlID by defaultand so it is puzzling why trying to 'correct' what is incorrect by ovveriding the value - would cause the error?
Does theDynamicServicePath have any purpose if you are not using the dynamic population feature? Otherwise can chalk this up as being a potential issue down the road if I start to use the dynamicservices features...
Thanks!
Relatively easy code fix for the Dynamic Service Path... For sites like mine where I do url rewriting as all content is database driven the following change needs to be applied:
in the ServicePathConverter.cs
namespace AjaxControlToolkit {
publicclassServicePathConverter :StringConverter {
publicoverrideobject ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture,object value,Type destinationType) {
if (destinationType ==typeof(string)) {
string strValue = (string)value;
if (String.IsNullOrEmpty(strValue)) {
HttpContext currentContext =HttpContext.Current;
if (currentContext !=null) {
//OLD
// return currentContext.Request.FilePath;
//Changed by Jody to allow sites that rewrite urls not to
//have paths = /<root>/default.aspx
return currentContext.Request.RawUrl;
}
}
}
returnbase.ConvertTo(context, culture, value, destinationType);
}
}
}
Otherwise, on sites that manage dynamic content and generate urls - the path will always be the root...The filepath works if say you have all 'static' pages in folders etc... but not in dynamically generated scenarios. The code fix will allow for both styles of content to be served properly.
No comments:
Post a Comment