Solved

ASP Alert Box

Posted on 2014-02-10
1
234 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 143

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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
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 …
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

634 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