ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2017 www.aspforums.com. All rights reserved.Show successful message after Insert, Update and Delete using C# in ASP.Net<p>Hi <a class="username" rel="yara"> yara</a>,</p> <p>I will get back to you soon.</p>http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/Mon, 09 Jan 2017 04:31:13 GMTShow successful message after Insert, Update and Delete using C# in ASP.Net<p>hI <a class="username" rel="yara"> yara</a>,</p> <p>After ExecuteNonQuery and connection Close write the below line of code to show the alert message. You just need to change the message as per the functionality(Insert,Update,Delete).</p> <pre class="brush: csharp">ClientScript.RegisterClientScriptBlock(this.GetType(), &#34;Message&#34;, &#34;alert(&#39;Record has been inserted successfully.&#39;)&#34;, true);</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/Tue, 10 Jan 2017 02:54:43 GMTShow successful message after Insert, Update and Delete using C# in ASP.Net<p>when I wrote it in the class of data access layer after connection close, it told me that "ClientScript" doesn't exist in the current context, and keyword "this" is not valid in a static property.</p> <p>Is the code that you gave me as the below code, means does it give the same output?</p> <p>&nbsp;</p> <pre class="brush: csharp"> string message = &#34;Record has been inserted successfully&#34;; string script = &#34;window.onload = function(){ alert(&#39;&#34;; script += message; script += &#34;&#39;)};&#34;; ClientScript.RegisterStartupScript(this.GetType(), &#34;SuccessMessage&#34;, script, true);</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/Tue, 10 Jan 2017 06:11:19 GMTShow successful message after Insert, Update and Delete using C# in ASP.Net<blockquote><cite>yara says:</cite> <div class="line number1 index0 alt2"><code class="csharp keyword">string</code> <code class="csharp plain">message = </code><code class="csharp string">"Record has been inserted successfully"</code><code class="csharp plain">;</code></div> <div class="line number2 index1 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp keyword">string</code> <code class="csharp plain">script = </code><code class="csharp string">"window.onload = function(){ alert('"</code><code class="csharp plain">;</code></div> <div class="line number3 index2 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">script += message;</code></div> <div class="line number4 index3 alt1"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">script += </code><code class="csharp string">"')};"</code><code class="csharp plain">;</code></div> <div class="line number5 index4 alt2"><code class="csharp spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="csharp plain">ClientScript.RegisterStartupScript(</code><code class="csharp keyword">this</code><code class="csharp plain">.GetType(), </code><code class="csharp string">"SuccessMessage"</code><code class="csharp plain">, script, </code><code class="csharp keyword">true</code><code class="csharp plain">);</code></div> </blockquote> <p>&nbsp;Replace above code with below.</p> <pre class="brush: csharp">string message = &#34;Record has been inserted successfully&#34;; string script = &#34;window.onload = function(){ alert(&#39;&#34;; script += message; script += &#34;&#39;)};&#34;; Page page = (Page)HttpContext.Current.CurrentHandler; ScriptManager.RegisterStartupScript(page, typeof(Page), &#34;ApprovalHistory&#34;, script, true);</pre> <p>&nbsp;</p>http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/Tue, 10 Jan 2017 07:02:09 GMTShow successful message after Insert, Update and Delete using C# in ASP.Net<p>Thank you, but what the difference between them? since they give the same output.</p>http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/Tue, 10 Jan 2017 07:10:14 GMTShow successful message after Insert, Update and Delete using C# in ASP.Net<p>Hi <a class="username" rel="yara"> yara</a>,</p> <p>Refer the below.</p> <h1 class="title"><strong>ScriptManager.RegisterStartupScript Method</strong></h1> <p>Registers a startup script block with the ScriptManager control and adds the script block to the page.</p> <p><a href="https://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript%28v=vs.110%29.aspx">https://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.registerstartupscript%28v=vs.110%29.aspx</a></p> <h1 class="title"><strong>ClientScriptManager.RegisterStartupScript Method</strong></h1> <p>Registers the startup script with the Page object using a type, a key, a script literal, and a Boolean value indicating whether to add script tags.</p> <p><a href="https://msdn.microsoft.com/en-us/library/z9h4dk8y%28v=vs.110%29.aspx">https://msdn.microsoft.com/en-us/library/z9h4dk8y%28v=vs.110%29.aspx</a></p> <p>&nbsp;</p>http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/http://www.aspforums.net/Threads/916372/Show-successful-message-after-Insert-Update-and-Delete-using-C-in-ASPNet/Tue, 10 Jan 2017 07:57:38 GMT