Fields.PageField control in Custom Module
Hi,
I have a module created using Module Builder which has PageField control to select the respective page. When I'm trying to create a new item then YSOD occurs with message below :
[ArgumentNullException: Value cannot be null.
Parameter name: virtualPath]
System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) +9799281
Telerik.Sitefinity.Web.UI.Fields.PageField.GetScriptDescriptors() +319
System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl) +128
Telerik.Sitefinity.Web.UI.SimpleScriptView.Render(HtmlTextWriter writer) +103
Anyone can help me on this?
Thanks,
Hello Yitro,
Would it be possible to give some information about your PageField control? If you share the code for this control I will try it on my test project? Also are you facing the same problem when you add this field to a built-in module?
Regards,
Kaloyan
Telerik
I will be interested to see how this pans out as well. I am seeing the same thing with what I am trying.
I have a custom module where I have a field that I selected to use a custom type for. In the virtual path I used 'Telerik.Sitefinity.Web.UI.Fields.PageField, Telerik.Sitefinity' hoping I could get the same functionality that is used in Sitefinity, but I am thinking there is more to it in this case.
Hi Kaloyan,
I created the field by using Module Builder > Content Type > Add field > Type: Short text, Interface widget for entering data: Custom, Type:Telerik.Sitefinity.Web.UI.Fields.PageField > continue > finish.
After that, I clicked Contents > Custom module > insert new item then the error occured. That's all. Also the same error occured when i want to insert a new news item after added custom field into News module. Thanks
Hi Yitro,
Your desired scenario cannot be achieved using this approach. In the attached file you can find a page selector sample which you can use.
Add the attached PageSelectorSample project to the Sitefinity project and Visual studio and it have added references to Sitefinity 6.0 assemblies (change the PageSelectorProject Telerik references if you want to use the field in different sitefinity version).
To use the field build in Visual studio and it will generate PageSelectorSample.dll, add reference to the project .dll in your sitefinity site and build it. To use the control:
1. Add Global.asax to the project and in it register the PageSelectorSample dialog that will open for selecting pages.
protected void Application_Start(object sender, EventArgs e)
Bootstrapper.Initialized += new EventHandler<
Telerik.Sitefinity.Data.ExecutedEventArgs
>(Bootstrapper_Initialized);
public void Bootstrapper_Initialized(object sender, Telerik.Sitefinity.Data.ExecutedEventArgs e)
Telerik.Sitefinity.Web.UI.Dialogs.RegisterDialog<
PageSelectorDialog
>();
Hi Kaloyan,
Actually I already have the similar control before, but when i explored Sitefinity Fields i found that PageField control. I thought i can use it in place of my custom control. Is it a bug or is the PageField can be use in the different case?
Thank you.
Hi Yitro,
This field cannot be used in this way and this is the reason why I am suggesting to use the provided solution. Using Telerik.Sitefinity.Web.UI.Fields.PageField will always lead to null error.
Regards,
Kaloyan
Telerik
Hi Kalayon,
Thanks for your info.
I've got a virtual path null error. I restarted the app in IIS and also made a dummy change to the web.config? Is that what you meant? I'm still getting a virtual path error whatever I do. I also notice that the ResolverType property never seems to save and is empty when I go back into the settings to check it. See below:
value cannot be null.
Parameter name: virtualPath
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.ArgumentNullException: Value cannot be null.
Parameter name: virtualPath
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:
[ArgumentNullException: Value cannot be null.
Parameter name: virtualPath]
System.Web.VirtualPath.Create(String virtualPath, VirtualPathOptions options) +12887950
Telerik.Sitefinity.Web.UI.Fields.PageField.GetScriptDescriptors() +471
System.Web.UI.ScriptControlManager.RegisterScriptDescriptors(IScriptControl scriptControl) +176
Telerik.Sitefinity.Web.UI.SimpleScriptView.Render(HtmlTextWriter writer) +146
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +15
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +52
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +15
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +52
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +15
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +52
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
ASP.templates_telerik_sitefinity_resources_templates_backend_contentui_detailview_ascx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) +872
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +131
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +15
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +52
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +15
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +52
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.WebControls.WebControl.RenderContents(HtmlTextWriter writer) +15
System.Web.UI.WebControls.WebControl.Render(HtmlTextWriter writer) +52
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +395
System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +49
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +249
System.Web.UI.Page.Render(HtmlTextWriter writer) +40
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +150
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5363
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.18446
Did you ever figure this out Mike?
I followed the steps above and I get the same error. Posted below.
Maybe I'm not adding it correctly?
Value cannot be null.
Parameter name: key
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.ArgumentNullException: Value cannot be null.
Parameter name: key
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:
[ArgumentNullException: Value cannot be null.
Parameter name: key]
System.Collections.Generic.Dictionary`2.FindEntry(TKey key) +10627293
System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value) +12
Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.BrowserLinkExecutionListener.FindSourceFile(PageExecutionContext context, RenderedSourceFile& sourceFile) +81
Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.BrowserLinkExecutionListener.OpenRenderRange(PageExecutionContext context, Int32 renderedStartPosition) +60
Microsoft.VisualStudio.Web.PageInspector.Runtime.Tracing.BrowserLinkExecutionListener.BeginContext(PageExecutionContext context) +135
Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.Begin(TextWriter writer, String file, Int32 start, Int32 length, Boolean literal) +343
Microsoft.VisualStudio.Web.PageInspector.Runtime.WebForms.SelectionMappingRenderTraceListener.BeginRendering(TextWriter writer, Object renderedObject) +241
System.Web.UI.RenderTraceListenerList.BeginRendering(TextWriter writer, Object renderedObject) +98
So I got this working, it appears to be a caching issue. I tried to clear everything, but I must've messed up. I deployed the solution and it worked, putting the guid ID in the short text field.
I still wish there was a better option in 6.3 for this. I read online that it IS a feature of 7.2 for dynamic modules.
Thanks!