C# | ASP.NET/ASP.NET
ASP.NET Code Behind에서 사용자 확인 후 액션 호출
bboks.net
2011. 6. 17. 11:56
ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> html xmlns="http://www.w3.org/1999/xhtml" > head runat="server"> <title>Untitled Page</title> <script type="text/javascript" language="javascript"> function ShowConfirmation() if(confirm("Are you want to show the value?")== true) //Calling the server side code after confirmation from the userdocument.getElementById("btnAlelrt").click(); </script> head> body> <form id="form1" runat="server"> <div> <asp:TextBox ID="txtDetails" runat="server"></asp:TextBox> <br /> <asp:Button ID="btnDetails" runat="server" Text="GetValue" OnClick="btnDetails_Click" /> <asp:Button ID="btnAlelrt" runat="server" Text="GetDetails" OnClick="btnAlelrt_Click" /> <br /> <br /> </div> </form> body> html>
Code Behind
using System;
using
System.Data;using
System.Configuration;using
System.Web;using
System.Web.Security;using
System.Web.UI;using
System.Web.UI.WebControls;using
System.Web.UI.WebControls.WebParts;using
System.Web.UI.HtmlControls;public
partial class _Default : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
//hide the button from users visibilitybtnAlelrt.Style.Add(
"display", "none");}
protected void btnDetails_Click(object sender, EventArgs e){
//Write your code which you wish to execute before the Confirmation from the USer
Page.ClientScript.RegisterStartupScript(
}
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(
}
}
[출처] User confirmation from code behind