Rails 7.0 with turbo back button is not working - ruby-on-rails-7

I am building an app with rails 7.0
<turbo-frame id="<%= item.id %>">
<div><%= item.id %></div>
<div><%= item.item_type %></div>
<a href="<%= edit_item_path(item.id) %>"
data-turbo-frame="_self">
edit item
</a>
</turbo-frame>
The edit view loads the new content successfully, but there is no back button functionality on this scenario. How can I enable back button?

I had to add data-turbo-action="advance" in my link, although according to the documentation that behaviour should be the default one.
<a href="<%= edit_item_path(item.id) %>"
data-turbo-frame="_self"
data-turbo-action="advance">

Related

Asp.net How to make the 'link text' from a 'search bar' href configurable

I would like to be able to use an 'AppSettings' key in Web.config to assign a value to the href 'link text'.
So, in the below sample code, I would like to make *Add Order* configurable.
<%# Control Language="C#" AutoEventWireup="true" CodeFile="menu.ascx.cs" Inherits="WebUserControl" %>
<ul class="topnav" id="myTopnav">
<li class="searchBar">
<input id="searchBox" type="text" name="search" placeholder="Order #" onkeypress="quickSearch(event);">
</li>
<li>Manage Order</li>
<li>*Add Order*</li>
<li><a class="active" href="DashBoard.aspx">DashBoard</a></li>
</ul>
This is the solution I settled on:
<li><asp:HyperLink ID="AddOrderButton" runat="server" CssClass="form-group"
NavigateUrl="AddOrderForm.aspx" Text="<%$ Appsettings:AddOrderButton %>">
</asp:HyperLink> </li>
You need to use this code to read from the config file and use the value. Firstly you need to make sure to import the namespace at the top of your file:
<%# Import Namespace="System.Web.Configuration" %>
Then read from it and use it:
<%= WebConfigurationManager.AppSettings["yourKey"] %>

Remove file extension on download using an ASP.NET HttpHandler?

I have stored file in my server, clients can download files via my page Home.aspx by clicking on an anchor, but i want to edit the original filename before launching download. How can i do it using an ASP.NET HttpHandler. Thanks in advance.
This is my anchor code:
<% if (document.Path != null) { %>
<a id="downloadLink" runat="server" style="margin: 5px" href="<%# CONTENT_DIRECTORY_ROOT + document.Path %>">
<%= LanguageManager.GetValue("LABEL_DOWNLOAD") %></a>
<% } %>
Try the RewritePath(newUrl) method
HttpContext.Current.RewritePath(sUrl)
Or you could use
HttpContext.Current.Server.Transfer(sUrl)

My <% %> not working in div. Why?

I've tried both snippets below. Nothing. I've tried <%#, <%=, and <%. Nothing. So I'm stuck.
<div style="background-color:Gray; color:white; text-align:center; width:100%;">
<asp:HyperLink ID="HyperLink1" Target="_blank" NavigateUrl='<%= Server.HtmlEncode(String.Format("~/ShowHistory.aspx?section={0}&jobnumber={1}", "APQP Header", "101244")) %>' runat="server">Show Updated History</asp:HyperLink>
<asp:HyperLink Target="_blank" NavigateUrl="~/ShowDeletedHistory.aspx" ID="HyperLink2" runat="server">Show Deleted History</asp:HyperLink></div>
<br />
<div style="background-color:Gray; color:white; text-align:center; width:100%;">
<asp:HyperLink ID="HyperLink1" Target="_blank" NavigateUrl='<%= String.Format("~/ShowHistory.aspx?section={0}&jobnumber={1}", "APQP Header", "101244") %>' runat="server">Show Updated History</asp:HyperLink>
<asp:HyperLink Target="_blank" NavigateUrl="~/ShowDeletedHistory.aspx" ID="HyperLink2" runat="server">Show Deleted History</asp:HyperLink></div>
<br />
Try <%# ... %> and call this.DataBind() (or Me.DataBind()) when your page loads.
Server controls cannot contain this type of tags. The reason is that "<%= %>" is basically equal to Response.Write, which itself executes after the page has gone through its lifecycle, when the response is already constructed. If you use it when setting a value of a server-side control property, this value has to be resolved when (or a little after) parsing the page markup. This is the reason you cannot use "<%= %>" in a server control.
If it was a normal html tag, it would work, but the virtual URL would not.
Is there a reason you're not setting the NavigationUrl in code? It would look much nicer to me.

target=_blank opening with same url

I added HyperLink control in my page. When I enter "http://www.google.com", It is opening in new window (good) and pointing google.
1. When I enter "www.google.com", It is opening in new window, but Url is "http://mysite.com/www.google.com". Why this is happing? How to should point to www.google.com
<a href= '<%# Eval("ConferenceUrl") %>' runat ="server" id="ConferenceUrl"
target="_blank"> <%# Eval("ConferenceUrl")%> </a>
You need http:// in the url, I believe.
The <%# Eval("ConferenceUrl") %> needs to have the http:// prefix. Either change your data or add it to the href attribute.
<%# Eval("ConferenceUrl")%>
you have to add http:// in the beginning of href

Why a <a href="~/#link"> when run become <a href="#link#link"> in a master page?

I never saw that problem and I have no idea what is causing it.
I got something like this code in my masterpage
<div class="myClass1">
<a href="~/#link" runat="server" title=" <%$ Resources: myRess1 %>">
<asp:Literal runat="server" Text="<%$ Resources: myRess1 %>" /><br />
<img class="myClass2" src="/MasterPage/images/myGif.gif" width="19" height="12" alt="" />
</a>
</div>
when I browse a page that using this master page, the code become
<div class="myClass1">
<a href="#link#link" title="myTitle">
myTitle<br />
<img class="myClass2" src="/MasterPage/images/.gif" width="19" height="12" alt="" /><br />
</a>
</div>
why does the link double itself?
if I put something like default.aspx instead of #link, it work perfectly.
The reason why I'm using "~/" is because the master page is located somewhere else, if I don't put ~/ it make the link as /masterpage/#link which is invalid
The ~/ should not be necessary. Just use #link
'~' can be used only with server controls and not with html controls. You should just use href="#link".
for now I changed my
<a href="~/#link" runat="server" title=" <%$ Resources: myRess1 %>">
to
<a href="#link" title="<%=GetLocalResourceObject("myRess1 ") %>">
and it's working fine but if someone could tell me why with runat="server" screw up the #link, that would be good to know

Resources