Solved

ASP Alert Box

Posted on 2014-02-10
1
227 Views
Last Modified: 2014-05-29
Hi,

I am Using Alert Box for  Display Information.If I click on Ok in Alert, I want to set ISPostback property on page load. Can u plz give example how to do?

Here my alert box code :
Page.ClientScript.RegisterStartupScript(this.GetType(), "ALERT", "alert('Deleted Successfully');", true);

if I click Ok on Alert I want to execute below method.
protected override void CreateChildControls()
        {
                   
                if (Page.IsPostBack)
                {
                    display1();
                }
           
        }
0
Comment
Question by:mannevenu26
1 Comment
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 39847252
you will need these items, a hidden field:
<asp:HiddenField id="HiddenField1" runat="server" />

Open in new window


a javascript function:
<script type="text/javascript">
 //in javascript fist check for postback because it is registered on page load
function validate()
{
   var blnPostBack = '<%= Page.IsPostBack ? "true" : "false" %>';
   if (blnPostBack == 'true')
   {
       if(!confirm('Are you sure to submit?'))
       {
            document.getElementById('<%= HiddenField1.ClientID %>').value=0;
       }
    }
    else
    {
       document.getElementById('<%= HiddenField1.ClientID %>').value=1;
    }
} 
</script> [code]

finally, in your asp page: [code]protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
             ScriptManager.RegisterStartupScript(this, typeof(string), "alert", "validate();", true);
        }
      
    }

Open in new window

and your code changes to:
protected override void CreateChildControls()
{
         int result1=Convert.ToInt32(HiddenField1.Value);
         if (result1 == 1 && IsPostBack)
        {
        }
} 

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now