How to set title programmatically in sitefinity mvc - sitefinity

Can you please help with setting the title as page name not data from the widget in Sitefinity?
I have tried
var urlName = SiteMapBase.GetActualCurrentNode().UrlName;
var pageHandler = this.ViewContext.HttpContext.Handler.GetPageHandler();
pageHandler.Title = urlName.ToUpperInvariant();
pageHandler.Page.Title = "MyTitle";
But it doesn't work. A version of Sitefinity 13.1.

At what stage of the page lifecycle are you setting it?
Most probably Sitefinity rewrites this after your code.
Your best bet is to place your code on PreRenderComplete event.
So, you know how you found the pageHandler - try subscribing to its PreRenderComplete event and in there set the Title of the page.

Do you just simply mean
ViewBag.Title = "My title";
In a controller action?

This works 12.2 but could not try 13.1
SiteMapBase.GetActualCurrentNode().Title

Related

Disable the back button in navigation bar

I need to get rid of only the arrow in the navigation bar in Xamarin forms. I tried in but I didn't get a proper solution. please help me overcome this issue. Thanks in advance.
!! I NEED TO REMOVE PERMANENTLY
solutions that I'm tried up to now :
Shell.SetBackButtonBehavior(this, new BackButtonBehavior
{
IsEnabled=false
});
but still, this didn't help me
There is a easy workaround to solve this.
You could override a Icon with a transparent png file(Follow is a transparent png):
and set enabled be false as follows:
Shell.SetBackButtonBehavior(this, new BackButtonBehavior
{
IconOverride = "transparent.png",
IsEnabled = false
}) ;
Then the effect as follows:
Note: You will see that we also can tap that area, therefore we need to set enabled be false.
Based on this official sample to test that.
You can set this using the Xamarin.Forms.NavigationPage class, from within a view's code behind file. E.g. within a ContentPage's constructor.
NavigationPage.SetHasBackButton(this, false);

How to refresh on closing dijit.dialog

I'm using dijit.dialog to show the popup dialog. How do I refresh the parent page on closing dijit.Dialog? Please advise. thanks
You need to add a listener to the hide event, and you need location.reload(). It will be a lot easier to answer your question if you post some code and list what you've tried already.
Here's a jsfiddle illustrating how to use location.reload() when a dijit/Dialog closes with Dojo 1.8.
The relevant code:
d.on('hide', function() {
console.log('closed');
location.reload();
});
You can use code as below, you just need to now your modal object's name.
var dialog = registry.byId("modalDialogObjectName");
var url = dialog.get("href");
dialog.set("href", url);

Dynamic content in User Control [Metro app, xaml]

I'm approaching to Metro App development in this days, so please be gentle.
I have created a User Control - some buttons and textblocks- that is loaded in every page of my app. I want the texblocks to change dynamically depending on the page selected: for example one of the texblocks of the user control is the page title. How can I accomplish this?
you can go for a simple code by finding the children of the usercontrol you are adding.
xaml code
xmlns:newPage="using:TestApp"
add the page like this in say mainpage.xaml:
<newPage:TestPage x:Name="pageNew"></newPage:TestPage>
then from code behind of the mainpage ie mainpage.xaml.cs
public mainpage(){
InitializeComponent();
var newPageContent = pageNew.Content; //here content will give u the immidiete children of usercntrl
}
Now you can type cast like
(Grid)newPageContent = pageNew.content;
var TextBlockFirst = newPageContent.children[0];
and so on :) please check if the suggestion is helpful :)

Clearing FlipTileData BackBackgroundImage

I have a periodic task that updates my live tile. Basically it looks like this:
var tileData = new FlipTileData()
{
BackgroundImage = mediumFrontUrl,
BackBackgroundImage = mediumBackUrl,
WideBackgroundImage = wideFrontUrl,
WideBackBackgroundImage = wideBackUrl
};
ShellTile primaryTile = ShellTile.ActiveTiles.First();
if (primaryTile != null)
{
primaryTile.Update(tileData);
}
There are certain occasions where I would like to not display the BackBackgroundImage and WideBackBackgroundImage. How do I clear the values? Simply setting things to null doesn't work (it just keeps what was there previously). According to the docs if I use XAML to create the live tile I can set Action="Clear". How do I set that in code?
You can clear the property for each Tile property.
For BackBackgroundImaga it's Empty URI:
BackBackgroundImage = new Uri("", UriKind.Relative)
More info on msdn page Tiles Overview for Windows Phone:
http://msdn.microsoft.com/en-us/library/hh202948%28v=vs.92%29.aspx
Hope this help
Best regards
And Zik
Just one trick.
Playing with WideBackContent and putting my own image (I have a lot of more possibilities with this apporach) I have problem with resetting WideBackContent. The thing that help me is not WideBackContent ="", then WideBackContent = " "
So, one empty space solved my problem.
Best regards

Captcha image and raw format

I've trying to get properly work kcaptcha class from kcaptcha.ru in my own component. 'Cause class not build for Joomla natively I break my brain on the wall.
And at the beginning...
I've a url to image generated by this class like: http://.../index.php&task=captcha&format=raw
In main controller I've put method
function captcha() {
include(JPATH_COMPONENT.DS.'libraries'.DS.'captcha'.DS.'kcaptcha'.DS.'kcaptcha.php');
$session = &JSession::getInstance('default', array());
$captcha = new KCAPTCHA();
if ($session) {
$session->set('captcha_keystring', $captcha->getKeyString());
}
}
And I've see in browser
When I request an image from the class all working good but in my component I cannot set session variables.
Any ideas how to fix this problem?
And problem solved successfully.
For &format=raw in controller Joomla set default mime-type to text/html.
For healing this issue developer must reset mime/type via setting
$document = &JFactory::getDocument();
$document->setMimeEncoding('image/png');
mime/encoding off course depends on you needs.