Why Umbraco replace hostname/subdomain in external link - asp.net

I am using webforms with Umbraco 7.6.3 I have simple menu(not using template) on my master page (/masterpages/Master.master) like this:
<li class="dropdown">
Home
<ul class="dropdown-menu">
<li><a runat="server" href="https://sub1.test.mywebsite">Home</a></li>
</ul>
</li>
if I don't add www In href Umbraco replace hostname/subdomain.
Am I missing any setting?

Uhm. You have to have a protocol, like http or https, in front of your link. So https://www.google.com is a valid link.

You need write code like this:
<div>
<ul>
<li><a>Home</a></li>
<li><a>aboutus</a></li>
<li>Search</li>
</ul>
</div>

Related

Navigating through a webpages that uses function instead of url with Jsoup

<div class="pb_ft clearfix" style="width:500px;clear:both;margin-top:50px;">
<div class="turn_page" id="list_navigator" style="margin-left:200px;">
<ol style="width:980px;">
<li style="width:100px;border:0">12129 Pages</li>
<li class="turn_pre">Last Page</li>
<li>1</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
<li class="turn_next">Next Page</li>
</ol>
</div>
<!--Next Page-->
</div>
It uses a href = "#" and then a function "PageContext.PageNav.go(2, 12128).
It appears that 12128 total pages are loaded by calling a JavaScript function.
What is the best way to navigate through these webpages? Should I better simulate a button click or I could invoke the website's function to make it flip pages.
Jsoup is an HTML parser and isn't a browser. With that being said, it's still possible to look at what is being returned in the url after you've clicked on a menu option.
If it's something predictable you can append the needed params to the URL to grab with Jsoup. If not, you're going to have to use something like Selenium to cycle through the menu then parse each page with Jsoup.
You could also try and disable Javascript in your browser to see how the website handles it. It could take you to a nav that doesn't use js. It's worth a shot.

Selenium - How to find an object without it having and Id or a Name?

I have recently started using Selenium Webdriver for automation. The webpage I'm trying to automate is in CSS. So what I'm try to achieve is click on a dropdown "Admin", which will then show a list. And select one of the options "User Access" from that list.
Now in the page source, this particular dropdown "Admin" does not have an ID or a Name. Below is the code for reference:
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
Admin<span class="caret"></span>
</a>
<ul class="dropdown-menu" role="menu">
<li>
<a href="usersAdmin">
Users Admin
</a>
</li>
<li>
<a href="userAccess">
User Access Admin
</a>
</li>
<li>
<a href="#">
Email Object Admin
</a>
</li>
</ul>
</li>
Now I want to select the User Access Admin value from the dropdown? I'm trying to use the findElement method to identify that object, but since it doesn't have an ID or a name, I'm not able to do that successfully. What would be a suitable method to do this?
I'm using Java for coding.
You could do this:
Java
WebElement element = driver.findElement(By.linkText("Users Admin"));
C#
var element = driver.FindElement(By.Name("Users Admin"));
Python
from selenium.webdriver.common.by import By
element = driver.find_element(By.NAME, "Users Admin")
Should the following css be sufficient?
a[href='userAccess']
In your case if you want to open the dropdown and choose the "Users Admin" option, then try the following:
// find the dropdown and open it
driver.findElement(By.linkText("Admin")).click();
// find the interesting element and select it via a click
driver.findElement(By.linkText("Users Admin")).click();

Getting errors on redirect only from certain pages

I have a menu in my Site.Master file whose code is as follows;
<nav>
<ul id="css3menu1" class="topmenu">
<li class="topfirst"><span>Home</span>
<ul>
<li>Employee Login</li>
<li>Customer/Distributor Login</li>
</ul>
</li>
<li class="topmenu"><span>Products</span>
<ul>
<li>Page1</li>
<li>Page2</li>
<li>Page3</li>
</ul>
</li>
<li class="topmenu"><span>Investor Info</span>
<ul>
<li>Quarterly Filings</li>
<li>Press Releases</li>
<li>Investor Updates</li>
<li>Company Presentations</li>
<li>Management Team</li>
</ul>
</li>
</ul>
</nav>
When I go to the sites login page BUT do not login and try to go to any of the links in the menu I get a 404 error page which says I'm trying to redirect to /Account/Page1.aspx.
Why is the "Account/" getting inserted into that path when the path from the Site.Master is clearly only Page1.aspx. I've tried changing the href to ~/ and ../ infront of the page name but that produced different types of errors ALTHOUGH it did properly redirect ONLY when in the login page (which is in the Account folder)
When you access Login.aspx page It will in 'Account' Folder directory. When you try to access other links in menu, it will first check in current 'Account' directory if page is exist it will display page otherwise it throws error.
I suggest you require dynamic menu for this. when You access 'Account' directory page it will change the menu as per the 'Account' directory and link.
You can use literal control and Literal1.Text = 'HTML Menu Code'
Better practice to use the tilde symbol instead of a relative path but with this you will need to use the
runat="server"
in the tag.
what were the other errors you got with that approach?
edit
<li><a runat="server" href="~/Account/Login.aspx">Employee Login</a></li>
It was far easier, and much more practical solution to use Page.ResolveURL("~/Account/Login.aspx"). I used Page.ResolveURL for all the links in the menu and now it works seamlessly

why is my primarylinks menu is adding classes only for some items?

I have 2 menus defined, and I want to style them...
As I'm continuing a previous made drupal there is a menu that assigns classes to each entry (haven't discovered how it does that),
it's outputs something like this:
<ul class="menu">
<li class="leaf first"><a title="" class="flores" href="/huerto-urbano/flores">Flores</a></li>
<li class="leaf"><a title="" class="plantas" href="/huerto-urbano/plantas">Plantas</a></li>
<li class="leaf last"><a title="" class="verduras" href="/huerto-urbano/verduras">Verduras</a></li>
</ul>
notice the class="flores"?
now I've created another menu similar to that but the class="XXXX" disapeares..why?
<ul class="menu">
<li class="leaf first"><a title="" href="/ca/huerto-urbano/flores">Flors</a></li>
<li class="leaf"><a title="" href="/ca/huerto-urbano/plantas">Plantes</a></li>
<li class="leaf last"><a title="" href="/ca/huerto-urbano/verduras">Verdures</a></li>
</ul>
I would start by searching the template.php located in the theme directory for themed menu item functions. If the theme name is 'plants', for example, then search for the functions plants_menu_item or plants_menu_item_link. The logic to add the class attribute may be in there.
The second menu is for a different language. What you should do is check if the problem is because of the translate module. Multilanguage set up looks to be the culprit.

Highlighting the selected jquery tab using asp.net Master page

I am using jquery tabs(First,Second,Third) in multiple asp.net pages (First.aspx, second.aspx,Third.aspx) in my asp.net website and in each page i am writing the ul,li code.
For example in the First.aspx page I am writing the following code inside the 'ul' tag
<li class="current">First tab</li>
<li>Second tab</li>
<li>Third tab</li>
Similarly in the second.aspx,Third.aspx pages i am using the Class="current" to highlight the selected tab.Recently we have planned to move to Master pages.So the master page should contain the ul,li code for the tabs.But the problem is that I do not understand how to apply the class="current" to the selected tab,in the case of the master page.Could someone please help?
Thanks in advance.
Write a javascript function in your master page to set the current class on a tab. Each page can then call that function when it's loaded to set the current page.
Something like:
<li id='tab1'>First tab</li>
<li id='tab2'>Second tab</li>
<li id='tab3'>Third tab</li>
function setCurrentTab(selectedTab) {
$('li').removeClass('selected');
$('[id=selectedTab]').addClass('selected');
}
and in Second.aspx, for example:
setCurrentTab('tab2');

Resources