Hi Robert,
Try the code below?
Ken
Microsoft MVP [ASP.NET]
<%@ Page Language="VB" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub DropDownList1_SelectedIndexChanged _
(ByVal sender As Object, ByVal e As System.EventArgs)
Label1.Text = DropDownList1.SelectedValue.ToString
End Sub
Protected Sub Page_Load _
(ByVal sender As Object, _
ByVal e As System.EventArgs)
DropDownList1.Attributes.Add _
("OnChange", "if (!confirm('Change this?')){return};")
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Confirm Dropdownlist</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:dropdownlist id="DropDownList1" runat="server"
autopostback="True"
onselectedindexchanged="DropDownList1_SelectedInde xChanged">
<asp:listitem selected="True">Red</asp:listitem>
<asp:listitem>Green</asp:listitem>
<asp:listitem>Blue</asp:listitem>
</asp:dropdownlist><br />
<br />
<asp:label id="Label1" runat="server"></asp:label> </div>
</form>
</body>
</html>
<ro****@orisoft.co.ukwrote in message
news:11**********************@e3g2000cwe.googlegro ups.com...
>I have a dropdownlist with the autopostback set to true. I want the
user to be confirm whether they do indeed want to change the value,
which on post back fires a server side event (selectedindexchanged).
I have tried adding an onchange attribute "return confirm('sure u wanna
change this?';") but it will not postback regardless of the confirm
result and the value in the list does not revert back if cancel
selected.
Is there a solution?