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.Redirect to previous page on ASP.Net MasterPage Button Click using C# and VB.Net<p>Hi&nbsp;nauna,</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">HTML</span></strong></p> <p><strong>Master Page</strong></p> <pre class="brush: html">&lt;html xmlns=&#34;http://www.w3.org/1999/xhtml&#34;&gt; &lt;head runat=&#34;server&#34;&gt; &lt;title&gt;&lt;/title&gt; &lt;asp:ContentPlaceHolder ID=&#34;head&#34; runat=&#34;server&#34;&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;/head&gt; &lt;body&gt; &lt;form id=&#34;form1&#34; runat=&#34;server&#34;&gt; &lt;div&gt; &lt;asp:LinkButton ID=&#34;LinkButton2&#34; runat=&#34;server&#34; Enabled=&#34;false&#34;&gt;LinkButton&lt;/asp:LinkButton&gt; &lt;hr /&gt; &lt;asp:ContentPlaceHolder ID=&#34;ContentPlaceHolder1&#34; runat=&#34;server&#34;&gt; &lt;/asp:ContentPlaceHolder&gt; &lt;/div&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;</pre> <p><strong>CS Page</strong></p> <pre class="brush: html">&lt;asp:Content ID=&#34;Content1&#34; ContentPlaceHolderID=&#34;head&#34; runat=&#34;Server&#34;&gt; &lt;/asp:Content&gt; &lt;asp:Content ID=&#34;Content2&#34; ContentPlaceHolderID=&#34;ContentPlaceHolder1&#34; runat=&#34;Server&#34;&gt; &lt;asp:Button ID=&#34;btnResponseRedirect&#34; Text=&#34;Response Redirect&#34; runat=&#34;server&#34; /&gt; &lt;asp:Button ID=&#34;btnServerTransfer&#34; Text=&#34;Server Transfer&#34; runat=&#34;server&#34; OnClick=&#34;ServerTransfer&#34; /&gt; &lt;/asp:Content&gt;</pre> <p><strong>Default Page</strong></p> <pre class="brush: html">&lt;asp:Content ID=&#34;Content1&#34; ContentPlaceHolderID=&#34;head&#34; runat=&#34;Server&#34;&gt; &lt;/asp:Content&gt; &lt;asp:Content ID=&#34;Content2&#34; ContentPlaceHolderID=&#34;ContentPlaceHolder1&#34; runat=&#34;Server&#34;&gt; Default Page &lt;/asp:Content&gt;</pre> <p><strong><span style="text-decoration: underline;">Code</span></strong></p> <p><strong>C#</strong></p> <p>Master Page</p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (this.Page.PreviousPage != null) { LinkButton2.Attributes.Add(&#34;onClick&#34;, &#34;javascript:history.back(); return false;&#34;); LinkButton2.Enabled = true; } }</pre> <p>CS Page</p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { btnResponseRedirect.PostBackUrl = &#34;Default.aspx&#34;; } protected void ServerTransfer(object sender, EventArgs e) { Server.Transfer(&#34;Default.aspx&#34;); }</pre> <p><strong>VB.Net</strong></p> <p>Master Page</p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load If Me.Page.PreviousPage IsNot Nothing Then LinkButton2.Attributes.Add(&#34;onClick&#34;, &#34;javascript:history.back(); return false;&#34;) LinkButton2.Enabled = True End If End Sub</pre> <p>CS Page</p> <pre class="brush: vb">Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load btnResponseRedirect.PostBackUrl = &#34;Default.aspx&#34; End Sub Protected Sub ServerTransfer(ByVal sender As Object, ByVal e As EventArgs) Server.Transfer(&#34;Default.aspx&#34;) End Sub</pre> <p><strong><span style="text-decoration: underline;">Screenshot</span></strong></p> <p><strong><span style="text-decoration: underline;"><img src="https://i.imgur.com/8j0bizf.gif" alt="" width="249" height="167" /></span></strong></p>https://www.aspforums.net:443/Threads/205652/Redirect-to-previous-page-on-ASPNet-MasterPage-Button-Click-using-C-and-VBNet/https://www.aspforums.net:443/Threads/205652/Redirect-to-previous-page-on-ASPNet-MasterPage-Button-Click-using-C-and-VBNet/Wed, 09 Jan 2019 00:16:14 GMT