Fields.PageField control in Custom Module

Posted by Community Admin on 05-Aug-2018 06:16

Fields.PageField control in Custom Module

All Replies

Posted by Community Admin on 18-Sep-2013 00:00

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,

Posted by Community Admin on 20-Sep-2013 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 24-Sep-2013 00:00

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.

Posted by Community Admin on 25-Sep-2013 00:00

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

Posted by Community Admin on 27-Sep-2013 00:00

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>();
        

Go to Administration->Settings->Advanced->VirtualPathSettings->VirtualPaths on the right click create new and enter

VirtualPath: ~/CtrlSel/*
ResourceLocation: PageSelectorSample
ResolverType: EmbeddedResourceResolver

Save changes and restart the application for the virtual path to be in use otherwise the same error will be thrown.

Remove the old page field from your module and add new field the same way as adding PageField before using this type : PageSelectorSample.PageSelector.

Regards,
Kaloyan
Telerik
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 30-Sep-2013 00:00

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.

Posted by Community Admin on 02-Oct-2013 00:00

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

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 11-Oct-2013 00:00

Hi Kalayon,

Thanks for your info.

Posted by Community Admin on 08-Apr-2014 00:00

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

Posted by Community Admin on 04-Nov-2014 00:00

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

Posted by Community Admin on 05-Nov-2014 00:00

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!

This thread is closed