Aspx Page
<script type=”text/javascript” language=”javascript”>
function ShowConfirmation(){
if (confirm(“Are you want to show the value?”) == true) {
document.getElementById(‘<%= btnAlelrt.ClientID%>’).click();
}
}
</script>
<tr>
<asp:Button ID=”btnDetails” runat=”server” Text=”GetValue” />
<asp:Button ID=”btnAlelrt” runat=”server” Text=”GetDetails”/>
</tr>
Aspx.cs file
private void CustomInitilize()
{
this.btnDetails.Click += new EventHandler(btnDetails_Click);
this.btnAlelrt.Click += new EventHandler(btnAlelrt_Click);
}
protected void btnDetails_Click(object sender, EventArgs e)
{
//Write your code which you wish to execute before the Confirmation from the User
ScriptManager.RegisterClientScriptBlock(this, typeof(Page),
Guid.NewGuid().ToString(), “ShowConfirmation();”, true);
}
protected void btnAlelrt_Click(object sender, EventArgs e)
{
//write your code which you wish to execute after the confirmation from the user….
Page.ClientScript.RegisterStartupScript(this.GetType(), “showVal”, “alert(‘alert2’);”, true);
}
Leave a comment