QUOTE(rgfirefly24 @ 28 Apr, 2008 - 01:14 PM)

User clicks submit... pop up comes up with confirmation message + phone number. user hits ok to confirm phone number is correct or else clicks cancel if it is not.
The code offered should do just that, actually. Remember that ASP.NET pages only really do most things via postback. That "btnSubmit_Click" method will never be called until the form on the page is actually submitted. Now, the javascript confirm forces our submit button to preform the onclick action before it does the submit action. If the onclick action is false, it never submits.
Of course, it will just leave the sorry thing lying limp on the page. If you want the postback to always fire and somehow read the confirm results in the button event...
This should do it for you. Note you'll need to stick a hidden field on the form.
csharp
protected void Page_Load(object sender, EventArgs e) {
if (!Page.ClientScript.IsClientScriptBlockRegistered("SaveConfirmBlock")) {
string script = "<script>function SaveConfirm() { "
+ " document.getElementById('hfConfirm').value = "
+ " confirm("
+ " 'Phone number entered is ' + document.getElementById('txtSavePhoneNum').value + '. Is this correct?'"
+ " );"
+ " return true"
+ " }</script>";
Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "SaveConfirmBlock", script);
}
this.btnSubmit.Attributes.Add("onclick", "java script:SaveConfirm();" );
}
protected void btnSubmit_Click(object sender, EventArgs e) {
this.labMessage.Text = "Confirmed: " + hfConfirm.Value + "<br/>" + this.txtSavePhoneNum.Text;
}
Also, these cute little incode javascript adds are for people who are afraid of HTML. I think it's much easier to read if you just put them in your page structure.