ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Pass data from one page to another page on HTML Anchor Link click in JavaScript<p>Hi <a class="username" rel="Alauddin">Alauddin</a>,</p> <p>Please refer below article.</p> <h1 class="header"><a title="Send (Pass) Data (Values) from one page to another using jQuery'a" href="https://www.aspsnippets.com/Articles/Send-Pass-Data-Values-from-one-page-to-another-using-jQuery.aspx">Send (Pass) Data (Values) from one page to another using jQuery</a></h1> <p>In below sample, I have used sessionStorage properties.</p> <p>The sessionStorage properties allow to save key/value pairs in a web browser. The sessionStorage object stores data for only one session (the data is deleted when the browser tab is closed).</p> <p><span style="text-decoration: underline;"><strong>HTML</strong></span></p> <p><strong>CS.aspx</strong></p> <pre class="brush: html">&lt;div&gt; &lt;asp:Label ID=&#34;lblTable&#34; runat=&#34;server&#34;&gt;&lt;/asp:Label&gt; &lt;/div&gt; &lt;script type=&#34;text/javascript&#34;&gt; window.onload = function () { var table = document.getElementsByTagName(&#34;table&#34;); var trs = table[0].getElementsByTagName(&#39;tr&#39;); for (var i = 0; i &lt; trs.length; i++) { var tds = trs[i].getElementsByTagName(&#39;td&#39;); var cardno = tds[1].innerText; if (cardno.length &gt; 5) { var firstFour = cardno.substr(0, 4); var lastFour = cardno.substr(cardno.length - 4, cardno.length); var middle = cardno.substr(4, cardno.length - 8).replace(/[0-9]/g, &#34;*&#34;); var newLink = document.createElement(&#34;a&#34;); newLink.setAttribute(&#34;href&#34;, &#34;Default.aspx&#34;); newLink.setAttribute(&#34;onclick&#34;, &#39;return check(&#34;&#39; + cardno + &#39;&#34;)&#39;); text = document.createTextNode(firstFour + middle + lastFour); newLink.appendChild(text); tds[1].appendChild(newLink); } } } function check(cardno) { sessionStorage.setItem(&#34;cardNumber&#34;, cardno); } &lt;/script&gt;</pre> <p><strong>&nbsp;Default.aspx</strong></p> <pre class="brush: html">&lt;div&gt; &lt;asp:Button Text=&#34;Get Card Number&#34; runat=&#34;server&#34; OnClientClick=&#34;return GetCard()&#34; /&gt; &lt;asp:Label ID=&#34;lblCardNumber&#34; runat=&#34;server&#34; /&gt; &lt;/div&gt; &lt;script type=&#34;text/javascript&#34;&gt; function GetCard() { var card = sessionStorage.getItem(&#34;cardNumber&#34;); document.getElementById(&#39;lblCardNumber&#39;).innerHTML = card; return false; } &lt;/script&gt;</pre> <p><span style="text-decoration: underline;"><strong>Code</strong></span></p> <p><strong>CS.aspx.cs</strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append(&#34;&lt;table id=&#39;01717458720_CardList&#39;&gt;&#34;); sb.Append(&#34;&lt;tr&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;product_type&#39;&gt;CREDIT CARD&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;card_no&#39; abbr=&#39;*&#39;&gt;1111234567123456&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;card_status&#39;&gt;INACTIVE&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;acct_no&#39;&gt;N/A&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;name&#39;&gt;Mr. X&lt;/td&gt;&#34;); sb.Append(&#34;&lt;/tr&gt;&lt;tr&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;product_type&#39;&gt;DEBIT CARD&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;card_no&#39;&gt;0000000000000000&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;card_status&#39;&gt;ACTIVE&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;acct_no&#39;&gt;55555555555&lt;/td&gt;&#34;); sb.Append(&#34;&lt;td id=&#39;name&#39;&gt;Mrs. Y&lt;/td&gt;&#34;); sb.Append(&#34;&lt;/tr&gt;&lt;/table&gt;&#34;); lblTable.Text = sb.ToString(); } }</pre> <p><span style="text-decoration: underline;"><strong>Screenshot</strong></span></p> <p><img src="https://imgur.com/p9AgePS.gif" alt="" width="472" height="141" /></p>https://www.aspforums.net:443/Threads/240052/Pass-data-from-one-page-to-another-page-on-HTML-Anchor-Link-click-in-JavaScript/https://www.aspforums.net:443/Threads/240052/Pass-data-from-one-page-to-another-page-on-HTML-Anchor-Link-click-in-JavaScript/Wed, 03 Oct 2018 03:43:51 GMT