set page name programmatically

Vote:
 

Hi,

i set the page name programmatically in the global.asax:

static void Instance_CreatingPage(object sender, EPiServer.PageEventArgs e)

{

e.Page.PageName ="xxx"

}

 

 

This works fine but i need to disable\hide the filed(property) name in edit mode to prevent the user to change the text.

I tried 

static void Instance_LoadingPage(object sender, EPiServer.PageEventArgs e)

{

e.Page.Property["PageName"].DisplayEditUI = false;

}

but it doesn't work.

Suggestions?

 

 

 

#37928
Mar 24, 2010 10:27
Vote:
 

I'm not completely sure that this is the problem, but in CMS5 PageData object properties are read-only, so that might be what is stopping you. You should try doing this:

PageData writablePage = e.Page.CreateWritableClone();
writablePage.Property["PageName"].DisplayEditUI = false;

I also can't see you saving the changes anywhere.

DataFactory.Instance.Save(writablePage, EPiServer.DataAccess.SaveAction.Publish);

I hope that helps!

#37935
Mar 24, 2010 11:37
Vote:
 
#37938
Mar 24, 2010 11:51
Vote:
 

 

I set the value with

static void Instance_CreatingPage(object sender, EPiServer.PageEventArgs e)

{

e.Page.PageName ="xxx"

}

and it works fine.

But i need to hide the property "page name" when the user edit the page.

#37939
Mar 24, 2010 11:53
Vote:
 

Hi Ivan,

I think you could use Fredrik Haglunds code in this blog post: http://blog.fredrikhaglund.se/blog/2009/06/08/move-built-in-property-to-another-tab-when-editing/ , but instead set OwnerTab to "-1". I think that should work.

#37941
Mar 24, 2010 13:19
Vote:
 

Another way is to subclass PropertyStringControl and use EPiServer.Core.PropertyControlClassFactory.Instance.RegisterClass from your global.asax Application_Start event handler to inject your subclass. In that class you can, for example, render the editcontrol (Textbox) read-only if the property name is PageName.

#37948
Mar 24, 2010 14:57
Vote:
 

This is what we do to remove a property from edit mode:

Subscribe to to the LoadedPageEventHandler,
in it we do this: e.Page.Property.Remove("propname")

Regards,
Morten

#37951
Mar 24, 2010 15:38
Vote:
 
#37974
Mar 25, 2010 7:55
Vote:
 

Hi,

i used

private void EditPanel_LoadedPage(EditPanel sender, LoadedPageEventArgs e)

{

e.Page.Property["PageName"].OwnerTab = anotherTabIndex;

}

In this way the user can't see the prorperty Name on the main Tab.

 

/Ivan

#37975
Mar 25, 2010 7:57
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.