1
Vote

GradientButton does not fire click event

description

It appears that when a GradientButton has a confirm in the OnClientClick property that the subsequent postback does not fire the click event handler.
 
Code:
 
<body>
<form id="form1" runat="server">
<sharp:GradientButton runat="server" ID="GradientButton1" Width="750px" OnClick="GradientButton1_Click"
    ImageFormat="Jpeg" OnClientClick="alert('Sample alert.');">
    <GradientBackground BorderColor="#404000" BorderWidth="2" GradientStartColor="LightGray"
        GradientEndColor="Gray" RoundCornerRadius="2" Type="Vertical" />
    <Text Value="This GradientButton fires the Click event b/c it does not have a confirm in OnClientClick."
        HorizontalAlign="Center" VerticalAlign="Center" />
</sharp:GradientButton>
<br />
<sharp:GradientButton runat="server" ID="GradientButton2" Width="750px" OnClick="GradientButton1_Click"
    ImageFormat="Jpeg" OnClientClick="return confirm('Click OK.');">
    <GradientBackground BorderColor="#404000" BorderWidth="2" GradientStartColor="LightGray"
        GradientEndColor="Gray" RoundCornerRadius="2" Type="Vertical" />
    <Text Value="This GradientButton causes a post back but does not fire the Click event b/c it has a confirm in OnClientClick."
        HorizontalAlign="Center" VerticalAlign="Center" />
</sharp:GradientButton>
<br />
<asp:ImageButton runat="server" ID="ImageButton" AlternateText="ImageButton" OnClientClick="return confirm('Click OK.');"
    OnClick="ImageButton_Click"  />
</form>
 
<script type="text/C#" runat="server">

    protected void Page_Load(object sender, EventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("Page_Load");
    }
 
    protected void GradientButton1_Click(object sender, EventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("GradientButton1_Click");
    }
 
    protected void ImageButton_Click(object sender, ImageClickEventArgs e)
    {
        System.Diagnostics.Debug.WriteLine("ImageButton_Click");
    }

</script>
 
</body>

comments