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.Stop calling Master Page JavaScript function on some page in ASP.Net<p>Hi <a class="username" rel="nauna"> nauna</a>,</p> <p>What you can do is put the contentpage controls inside a div and assign a common class name for the page you want to execute the JavaScript function and don't assign any class for the page you don't want to execute the JavaScript function.</p> <p>Check this example. Now please take its reference and correct your code.</p> <p><strong><span style="text-decoration: underline;">MasterPage.master</span></strong></p> <pre class="brush: html">&lt;%@ Master Language=&#34;C#&#34; AutoEventWireup=&#34;true&#34; CodeFile=&#34;MasterPage.master.cs&#34; Inherits=&#34;MasterPage&#34; %&gt; &lt;!DOCTYPE html PUBLIC &#34;-//W3C//DTD XHTML 1.0 Transitional//EN&#34; &#34;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#34;&gt; &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;style type=&#34;text/css&#34;&gt; .modal { position: fixed; top: 0; left: 0; background-color: black; z-index: 99; opacity: 0.8; filter: alpha(opacity=80); -moz-opacity: 0.8; min-height: 100%; width: 100%; } .loading { font-family: Arial; font-size: 10pt; border: 5px solid #67CFF5; width: 200px; height: 100px; display: none; position: fixed; background-color: White; z-index: 999; } #lnkSubmit { background: none; border: none; color: #0066ff; text-decoration: underline; cursor: pointer; } &lt;/style&gt; &lt;script type=&#34;text/javascript&#34; src=&#34;http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js&#34;&gt;&lt;/script&gt; &lt;script type=&#34;text/javascript&#34;&gt; function ShowProgress() { setTimeout(function () { var modal = $(&#39;&lt;div /&gt;&#39;); modal.addClass(&#34;modal&#34;); $(&#39;body&#39;).append(modal); var loading = $(&#34;.loading&#34;); loading.show(); var top = Math.max($(window).height() / 2 - loading[0].offsetHeight / 2, 0); var left = Math.max($(window).width() / 2 - loading[0].offsetWidth / 2, 0); loading.css({ top: top, left: left }); }, 200); } $(&#39;form&#39;).live(&#34;submit&#34;, function () { if ($(&#39;.FunctionRequired&#39;).length &gt; 0) { ShowProgress(); } }); &lt;/script&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 class=&#34;loading&#34; align=&#34;center&#34;&gt; Loading. Please wait.&lt;br /&gt; &lt;br /&gt; &lt;img src=&#34;Images/progress.gif&#34; alt=&#34;&#34; /&gt; &lt;/div&gt; &lt;div&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><span style="text-decoration: underline;">Page1.aspx</span></strong></p> <pre class="brush: html">&lt;%@ Page Title=&#34;&#34; Language=&#34;C#&#34; MasterPageFile=&#34;~/MasterPage.master&#34; AutoEventWireup=&#34;true&#34; CodeFile=&#34;Page1.aspx.cs&#34; Inherits=&#34;Page1&#34; %&gt; &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;div class=&#34;FunctionRequired&#34;&gt; &lt;asp:Button ID=&#34;btnSubmit&#34; Text=&#34;Submit&#34; runat=&#34;server&#34; OnClick=&#34;btnSubmit_Click&#34; /&gt; &lt;/div&gt; &lt;/asp:Content&gt; </pre> <p><strong><span style="text-decoration: underline;">Page1.aspx.cs</span></strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string script = &#34;$(document).ready(function () { $(&#39;[id*=btnSubmit]&#39;).click(); });&#34;; ClientScript.RegisterStartupScript(this.GetType(), &#34;load&#34;, script, true); } } protected void btnSubmit_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(1000); }</pre> <p><strong><span style="text-decoration: underline;">Page2.aspx</span></strong></p> <pre class="brush: html">&lt;%@ Page Title=&#34;&#34; Language=&#34;C#&#34; MasterPageFile=&#34;~/MasterPage.master&#34; AutoEventWireup=&#34;true&#34; CodeFile=&#34;Page2.aspx.cs&#34; Inherits=&#34;Page2&#34; %&gt; &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;div&gt; &lt;asp:Button ID=&#34;btnSubmit&#34; Text=&#34;Submit&#34; runat=&#34;server&#34; OnClick=&#34;btnSubmit_Click&#34; /&gt; &lt;/div&gt; &lt;/asp:Content&gt; </pre> <p><strong><span style="text-decoration: underline;">Page2.aspx.cs</span></strong></p> <pre class="brush: csharp">protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string script = &#34;$(document).ready(function () { $(&#39;[id*=btnSubmit]&#39;).click(); });&#34;; ClientScript.RegisterStartupScript(this.GetType(), &#34;load&#34;, script, true); } } protected void btnSubmit_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(1000); }</pre> <p>&nbsp;</p>https://www.aspforums.net:443/Threads/190366/Stop-calling-Master-Page-JavaScript-function-on-some-page-in-ASPNet/https://www.aspforums.net:443/Threads/190366/Stop-calling-Master-Page-JavaScript-function-on-some-page-in-ASPNet/Thu, 20 Sep 2018 01:39:49 GMT