Solved

ASP Alert Box

Posted on 2014-02-10
1
229 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
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.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

785 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