ASP.Net Faulty Link Creation - c#

I have just created a link to route in Site.Master but it have created a weird error
For example, when it was clicked, instead of http://localhost/Admin/ManageType it became http://localhost/~/Admin/ManageType.
I have tried to solve it myself by removing ~/ and it works but it come with a flaw. Once click it work and bring you to the page but when click again, it become http://localhost/Admin/Admin/ManageType instead of http://localhost/~/Admin/ManageType.
<ul class="nav navbar-nav">
<li><a runat="server" href="~/">Home</a></li>
<li><a runat="server" href="~/About">About</a></li>
<li class="dropdown">
Manage <b class="caret"></b>
<ul class="dropdown-menu">
<li>Recipe</li>
<li class="divider"></li>
<li>Type</li>
</ul>
</li>
<li><a runat="server" href="~/Recipe/Recipe">Recipe</a></li>
</ul>

Use Control.ResolveUrl method instead.
And you need to change:
<li>Recipe</li>
To:
<li><a href="<%= Page.ResolveUrl("~/Admin/ManageType") %>" title="ManageType" >ManageType</a></li>

Try this:
<li>Type</li>

Related

How to click on a tab with specific text?

I need to click on tab "Pis/Cofins" in my application
<ul class="nav nav-tabs" id="tabs">
<li class="">
Dados Gerais
</li>
<li class="active">
Pis/Cofins
</li>
<li>
Combustíveis
</li>
<li>
Modo de Servir
</li>
<li>
Imagens
</li>
<li>
Informações
</li>
</ul>
You may simply use the following xpath:
//a[text()='Pis/Cofins']
You may use extension like Firebug in firefox to easily find locators and use them in your test scripts
As per the HTML you have shared to click on tab with text as Pis/Cofins you can use either of the following solutions:
LinkText:
driver.FindElement(By.LinkText("Pis/Cofins")).Click();
CssSelector:
driver.FindElement(By.CssSelector("ul.nav.nav-tabs#tabs a[href$='pisCofins']")).Click();
XPath:
driver.FindElement(By.XPath("//a[contains(#href,'pisCofins') and contains(.,'Pis/Cofins')]")).Click();

Cannot use a leading .. to exit above the top directory (ASP.NET webforms)

I have an ASP.NET webforms project with a master page using adminlte UI.
I created a web site with default project in Visual Studio and then change the project to apply adminlte dashboard, copied all scripts and bootstrap then change master page and default form.
My problem: in menu sidebar when I tried to add from to root folder and do this
<li>
<a runat="server" href="Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
everything is ok and form loads without any problem.
But when I created a folder Track and created a new form inside it and try to do this
<li>
<a runat="server" href="~/Track/Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
I get this exception:
exception
What I tried
First attempt:
<li>
<a runat="server" href="../../Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
Second attempt:
<li>
<a runat="server" href="../Track/Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
Third attempt:
<li>
<a runat="server" href="~/../Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
Final attempt:
<li>
<a runat="server" href=~/Track/Shipment.aspx">
<i class="fa fa-th"></i><span>Shipment</span>
</a>
</li>
I've fixed some deprecated and superfluous markup - adjust any related CSS selectors.
Try this:
<li>
<a runat="server" href="~/Shipment.aspx">
<em class="fa fa-th">Shipment</em>
</a>
</li>
The "~/" should resolve anything from the main project root down, presuming there are no page name conflicts. Some of your attempts should have worked so I'm thinking maybe something else is causing a problem. Presuming your menu is in a User Control, maybe it's the path to this control in your Master Page(s) that is causing the problem?

Setting an element text outside server-tag

Is it possible to put Text in a element outside the <form runat="server"> tag?
I'm trying to at least output my Session values like the user's name in a <a> element.
In my login.aspx.cs i start the session
Session["username"] = firstname.Text;
and then try to output it on other pages navigation that is outside the <form> tag
<div class="collapse navbar-collapse" id="navbar-brand-centered">
<ul class="nav navbar-nav">
<li>Home</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><!--The place where i will output--></li>
<li>Logout</li>
</ul>
</div>
i tried to call the id of the <a> it doesn't appear in suggestion and i started to think that its outside the server tag.
Thank you for understanding and for helping.
Use it like <%# Session["username"].ToString() %>, you need not set from code behind, you will directly access to it.
<div class="collapse navbar-collapse" id="navbar-brand-centered">
<ul class="nav navbar-nav">
<li>Home</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><%# Session["username"].ToString() %></li>
<li>Logout</li>
</ul>
</div>

Dropdown master page didn't work after change page

Didn't work dropdownlist Risk Content in master page after change page to the setting page. The dropdown just work after go back to home page again
MasterPage.master
<div id="navbar" class="navbar-collapse collapse">
<ul class="nav navbar-nav custom_nav">
<li class="">Home
</li>
<li class="dropdown">Risk Context
<ul class="dropdown-menu" role="menu">
<li>Objective (KPI)
</li>
<li>Risk Limit & Expected Residual Risk
</li>
<li>Impact Scale Tables
</li>
<li>Probability Scale Tables
</li>
</ul>
</li>
<li>Settings
</li>
<ul>
</div>
What I miss from my code?? help me. thank before..

Styling orchard menu with custom css

Currently I am implementing an existing layout already implemented in MVC4 project.
I am struggling with how to implement a custom menu in the latest Orchard (using the source version so Orchard runs in Visual Studio).
The problem is where does the CSS get applied? The only thing I could find with google was changing the Menu.cshtml (one in core/shapes one in admin theme, clueless which one is the proper one). I cannot see any sign of css anywhere.
The html version of my menu has the following look:
<div id="cssmenu" class="fixedContentSize">
<ul>
<li class='active '><a href='index.html'><span>Home</span></a></li>
<li class='has-sub '><a href='#'><span>Dojo</span></a>
<ul>
<li class='has-sub '><a href='#'><span>Test</span></a>
<ul>
<li><a href='#'><span>Sub Item</span></a></li>
<li><a href='#'><span>Sub Item</span></a></li>
</ul>
</li>
<li class='has-sub '><a href='#'><span>Test2</span></a>
<ul>
<li><a href='#'><span>Sub Item</span></a></li>
<li><a href='#'><span>Sub Item</span></a></li>
</ul>
</li>
</ul>
</li>
<li><a href='#'><span>Media</span></a></li>
<li><a href='#'><span>Links</span></a></li>
<li><a href='#'><span>About</span></a></li>
<li><a href='#'><span>Contact</span></a></li>
</ul>
</div>
It gets applied in the theme's CSS. Look at site.css in the theme machine theme for an example.

Categories