Asp.net programming we consider all important topic for knowledge about controls,web Services, JSON, Ajax, database, and interview related Question. In this Asp.net and sql server tutorial blog we give many examples of jquery as like How Play YouTube Video in Your Asp.net Website by URL, How to Play YouTube Videos in Asp.net by using Jquery , Jquery Change div background on mouseover in asp.net , JQuery UI Datepicker (Calendar) etc.

Friday, January 9, 2015

JavaScript alert by C# code on asp.net web page by C#

JavaScript alert by C# code on asp.net web page by C# :

Redirect to a page/URL after alert button is pressed or implement javascript message in Code behind C#.

In this post we give a simple example to show javaScript alert message on asp.net web page by C#. Means we want to achive this by code behind page.

This is very simple some time we want to show some message on button click event or show when the condition is true or false . like that we consider a example we want to show a javaScript alert message by code if condition is true.

if (userTyle==”Admin”)
           {
               ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert('Notification : You are not user you are Admin .');” true);
           }

Redirect to a page after javascript alert has been dismissed in ASP.NET web page by C# code:


Some time we also want to display alert message and if javascript alert message dismissed then move to other web page.

if (userTyle==”Admin”)
           {
               ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "Notify", "alert('Notification : You are not user you are Admin .');window.location.replace('Adminhome.aspx');", true);
           }

If you want to redirect after a purely client-side event, you need to do it in client-side code. Something like this:

window.location.replace('pageName.aspx');


No comments:

Post a Comment