пятница, января 30, 2009

Specified argument was out of the range of valid values. Parameter name: utcDate

В очередной раз выкладывая на сервер приложение, заметил, что ajax-овый tab container control не загружает свои сборки..т.е. просто пропали стили обрамления самих вкладок, их подсветка при onmouseover, т.е. собственно то, что раньше отдавал ScriptResource.axd

Фидлером увидел 500 ошибку на обращение к обработчику ресурсов:


Specified argument was out of the range of valid values.
Parameter name: utcDate
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.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: utcDate

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
Parameter name: utcDate]
System.Web.HttpCachePolicy.UtcSetLastModified(DateTime utcDate) +3261043
System.Web.HttpCachePolicy.SetLastModified(DateTime date) +47
System.Web.Handlers.ScriptResourceHandler.PrepareResponseCache(HttpResponse response, Assembly assembly) +194
System.Web.Handlers.ScriptResourceHandler.ProcessRequest(HttpContext context) +1154
System.Web.Handlers.ScriptResourceHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext context) +4
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64





этот эффект происходит изза эффекта "assemplies in the future" :)
т.е. из-за разницы в таймзонах у меня сборка ушла на сервер с датой поздней, чем серверное время и обработчик ресурсов для ajax сходит с ума

Как решение, просто откомпилить сборку с датой ранее даты серверного времени;

пятница, января 23, 2009

Динамическое создание вкладок для ajax tab container

Динамическое создание вкладок для ajax tab container;
Ситуация была следующая - в разметке был размещен контейнер, для которого создавал вкладки динамически...
разметка:

<ajaxtoolkit:tabcontainer id="tabContainerCompanyProfile" runat="server" enableviewstate="true" width="100%">
</ajaxtoolkit:tabcontainer>


до постбека все происходило нормально, при переходе на другую страницу или при постбеке получал сообщение:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.

ну и stack trace до вызова set_ActiveTabIndex;

лечится только динамическим созданием самого tab container как показано ниже:
помещаем в place holder и затем уже добавляем вкладки...


разметка:


<table>
<tr>
<td>
<asp:PlaceHolder ID="phTabContainer" runat="server" EnableViewState="true">
</asp:PlaceHolder>
</td>
</tr>
...........................


фрагмент кода:


var availableTabs = (from pd in this.ProfileDescriptors
where pd.CompanyTypes.Contains(this.CompanyType) &&
(pd.EditMode == EditMode.All || pd.EditMode == this.ProfileMode)
select pd).ToList();


if (availableTabs != null &&
availableTabs.Count > 0)
{

AjaxControlToolkit.TabContainer tabContainer = new AjaxControlToolkit.TabContainer();
tabContainer.Width = Unit.Parse("100%");
tabContainer.Enabled = true;
tabContainer.Visible = true;

phTabContainer.Controls.Add(tabContainer);

foreach (ProfileDescriptor profileDescriptor in availableTabs)
{
foreach (TabDescriptor tabDescriptor in profileDescriptor.TabDescriptors)
{
CompanyProfileTabs.CompanyPropertiesTabBase propertiesEditor = (CompanyProfileTabs.CompanyPropertiesTabBase)this.LoadControl(tabDescriptor.TabControlURL);
if (propertiesEditor != null)
{
AjaxControlToolkit.TabPanel tab = new AjaxControlToolkit.TabPanel();
tab.Visible = true;
tab.Width = Unit.Percentage(100);
tab.Enabled = true;
tab.HeaderText = tabDescriptor.HeaderCaption;

propertiesEditor.Visible = true;
tab.Controls.Add(propertiesEditor);


tabContainer.Tabs.Add(tab);

this.Tabs.Add(propertiesEditor);
}
}

}

if (this.Tabs.Count > 0)
{
tabContainer.ActiveTabIndex = 0;
}
}