I want to write a code on the mvc master page please tell how shall I do that,My requirement is that I want to show the tab clicked as highlighted.
Please help me
Thanks
Ritz
use css :visited pseudo-class on link
Use css as stated by Jack and check the information on your current route to see what view your displaying, something like
Html.ViewContext.Controller.ControllerContext.RouteData.GetRequiredString("controller")
to get the current controller or replace controller with whatever data you need from the route. Then just add a condition to add a selected class or not on your tab.
Related
So this might sound silly but I'm really stuck. I have an HTML a tag in my cshtml layout view that is supposed to redirect to another cshtml view page. Despite trying different ways to generate the correct path, clicking on the link still returns 404 not found. Can someone please help me with this?
I realized I need to have a method in the controller for every view. Didn't know that before. It's working fine now. :)
You can use the asp-page tag helper to route to another page.
Below is an example:
<td><a class="text-info" asp-page="NameOfPageYouWantRoutedTo" asp-route-id="#Model.ID">#Model.ID</a></td>
Depending on where your new cshtml page is you may have change the filepath, but this should get you close. The asp-route-id tag helper would link whatever value of the link to the new page. Delete that tag helper if not needed.
This is a pretty good link on tag helpers that would be useful for what you're trying to accomplish.
I'm facing problem to hide action name controller name. I searched lot of articles but still I cannot get satisfactory answer. I can hide only controller name.
e.g.
www.mynewsite.com/Account/Registration
www.mynewsite.com/home/about
but I want same url like www.mynewsite.com only for all. Is it possible? If yes, how to achieve this?
You can do this trick using java script after loading your page.
just try within your document.ready function
window.history.pushState("object or string", "Title", "/");
Note: URL will be visible before loading your page.
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>
I have a following view in my gsp page.
Here I want to click or select one record in table and then click on 'SELECT' button. So that it will go to next page and show details. But I don't understand how to do it? Doesanyone has idea?
You could use AJAX methods in GRAILS something like this:
http://grails.org/AJAX-Driven+SELECTs+in+GSP
Also, this looks more of a Javascript question. So, tagging Javascript should help.
am developing an application in which i have to show the customer purchase details supplier wise. for that i have develop user control an add it on page. but the problem it that on user control i need to add a ling to promotional offer page for that supplier which show the current offers of the supplier. for that i have added the hyperlink as fallow to user control
<asp:HyperLink ID="PromoLink" runat="server">Have promo Code ?</asp:HyperLink>
and set the navigation URL as fallow
PromoLink.NavigateUrl = "Promotion.aspx?Filter=" + dt.Rows[0]["SuppId"].ToString();
but when page is load in does not render the navigation url to the link.
i donot why it does not render the url plz help to get out of this.
thanks in advance.
Make sure that the pathing is correct for the NavigateURL property. Try adding "~/" at the start of the NavigateURL or "../" if it is not in the same folder as the current file.
Make sure that the dt.Rows[0]["SuppId"] is actually getting the value that you expect.
Step through code in the debugger to verify that the Page_Load event that you are using is actually executing and modifying the value as you would expect it to.