Same link in menu and in footer are in different languages - asp.net-mvc

My ASP.NET MVC 4 website URLs looks like this "/language/controller/action".
HTML code of link in menu and in footer are the same.
<li>Website development</li>
When site is opened in "en-GB" culture link in menu pinting to
/en-GB/Service/WebsiteDevelopment
But link in footer is
/hy-AM/Service/WebsiteDevelopment
How it is possible? How can I fix this?

You don't specify "language" in Url.Action, so it probably takes the default language.
ASP.NET links are absolute ones, so without specifying the language, it's
/default-language/controller/action
If you want the language to be taken from the current URL, you need to write your own Url.Action function, or extend it.

Last menu was changing entire language to Armenian. Aa a route value it takes place after that function.

Related

Creating a multilingual link to a CMS page in Prestashop

I want to make a link to a CMS page in prestashop, the webshop has 3 languages. How do i make the link autoswitch the language?
When you make a cms-page, you can enter the translations for the title of that page. So i have to get that title in the code?
This is what i have now (which stays in English when i switch the language):
<a href='{$link->getCMSLink('8', 'about-us')}' title='{l s='About us'}'>{l s='About us'}</a>
Thanks!
Why don't you simply only pass the id_cms parameter? By providing an alias, you force the dispatcher to use this alias when creating the link.
If you use {$link->getCMSLink('8')} Prestashop will get the current language and find the proper alias in that language.

Changing page direction (Right-to-Left/ Left-To-Left) based on Localization settings in MVC 5

How can I change the page direction based on the local setting of the user? from left to right to right-to-left?
Should this be done using JS only, or there is a better way? please note that I need to Change to value, not check the current culture settings.
Using ASP.NET MVC5
Thanks
To set the text direction of the whole page in HTML 5, you can set the dir attribute on the html or body element. (In HTML 5 the dir attribute can be used on any element).
For instance if you're setting the CurrentThread CurrentCulture in the request, you can use the following in your view:
<html
dir="#(System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.IsRightToLeft? "rtl" : "ltr")">
Based on http://afana.me/post/aspnet-mvc-internationalization.aspx
Note that if you're using a CSS library such as bootstrap, you'll also need to get an rtl-modified version of the CSS, because the page direction won't affect css rules.

How to properly encode links to external URL in MVC Razor

This view suppose to show a list of hyperlinks, each pointing to an external URL. The goal is for the user to click one of these links and have their browser open a new tab with the selected URL.
Currently I have the following markup:
#Html.ActionLink("SomeSite", "http://subdomain.mydomain.com/SomeSite")
This markup produces:
http://localhost:58980/AccessInstance/http%3a/subdomain.mydomain.com/SomeSite
instead of :
http://subdomain.mydomain.com/SomeSite
What can I change in my markup to make this work as I expect?
You don't need to use #Html.ActionLink for that. Just use a plain A tag:
SomeSite
Html.ActionLink is specifically for generating links to actions defined in MVC controllers, in the same app. Since you're linking to an absolute URL, you don't need any of the functionality that Html.ActionLink provides.
Two ways :
1. update the database column with full link:
eg SQL:
update ProductTable set ProductLink='http://www.example.com/Product/Mobiles' where ID=123
In asp mvc view
View
2. Hardcode the http part and list from model
View
Hope helps someone.
While a ViewBag is overused and not the best choice most of the time this is something that I had done when inheriting someone else's mvc app to do a quick fix for a URL that I needed to redirect to with a specific dynamically changing querystring parameter
<a target="_parent" href="http://localhost:56332/services/#ViewBag.factory">View Service</a>
Using .NET Core 6
This seems to be the most correct answer:
Link
This will generate the following result:
As you can see at the bottom left corner of the window before clicking the link, the URL address was rendered as it is (NOTE: The cursor was recorded out of place for some reason, that's a ShareX problem, ignore it).
Than link will be directly saved as a nvarchar(750) type (probably any character like type will do the work). No changes to the original link were made before saving it or on reading:
You need to take into account your RouteConfiguration.
routes.MapRoute(
name: "Default",
url: "{controller}/{action}"
because you are specifying the action link as the entire link that you want to redirect.
I would recommend that you use the #rossipedia answer because you can make tricky things like putting a span inside the link
Here to display link that are clickable in index page
<td>
#Html.ActionLink(item.FileName, "../Uploads/Catalogue/"+item.FileName)
</td>

How to navigate?

Say I create an HTML file with two .page on it. In the first .page, I'd like to have a link to the second .page.
Is there a way to navigate between pages without having to write my own JS? This seems to suggest I do have to write JS: http://view.jquerymobile.com/1.3.2/dist/demos/widgets/navigation/.
However, I'd would rather set an id attribute for one of the pages, then maybe define some data attribute in the link to tell jQuery mobile where to go. Possible?
I'd also like to specify what kind of transition effect to use.
You can use standard anchor links, just give an id to your page and set the transition via the data attribute
Link to Page 2

Html.Action link and Html.RouteLink

Even If the url is same can i go to different action using Html.RouteLink and Action Link.Like when i click on news link i will go to news details.The url of this page is http://localhost:1390/en-US/latestnews/125.Now if i select the ddl of language in the site header in this pagei need to
go to the home page of the site.The ddl (on change) will take the same url but this time it needs to go to action in the sane controller.
The URL will direct to the controller/action on the first routing entry that it matches regardless of how you generate it. I'm not sure exactly what you are trying to accomplish, but I suspect that what you need to do is use javascript to direct to a different url, perhaps generated with Html.RouteLink instead of Html.ActionLink based on the value of the drop down list when it's selected. If I'm misunderstanding what you are trying to do, please clarify.

Resources