Can't do it with ASP.NET. Remember, ASP.NET is a
Server Side technology. Javascript is really your only hope.
There is a way to get confirmation on a button press, though. I'm not sure if it is what you need, but here it is if it helps you.
-
<!-- aspx file -->
-
<asp:Label ID="lConfirmed" runat="server" Text="Not Confirmed" /><br />
-
<asp:Button ID="bConfirm" runat="server" Text="Confirm?"
-
OnClientClick="return confirm('Are you sure?');"
-
OnClick="bConfirm_Click" />
-
-
//.aspx.cs file
-
protected void bConfirm_Click(object sender, EventArgs e)
-
{
-
lConfirmed.Text = "Confirmed";
-
}
-
This will run the javascript in the OnClientClick, and if it returns true, run the server code. Else, cancel the postback.