Solved

ASP Alert Box

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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

746 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

13 Experts available now in Live!

Get 1:1 Help Now