简体   繁体   中英

OnClientClick doesnt work in Formview asp.net

I am working in asp.net vb.net. I have a datagrid with a update button like this : OnClientClick="return ('Succesfully updated!')"> Which works like a charm.

And I have this one in the formview:

OnClientClick="return ('Succesfully edited!')">

Its exactly the same button as in the gridview, but it doesnt seem to work? Complete buttons:

      <asp:Button 
        ID="ButtonUpdate" 
        runat="server" 
        CssClass="details"
        CausesValidation="True" 
        CommandName="Update" 
        Text="Update"
        OnClientClick="return
        ('Succesfully updated')">
    </asp:Button>

The other one is exactly the same but with different text and a other ID

I think you are try to fire alert() function on client click try this:

<asp:Button ID="ButtonUpdate" runat="server" 
        CssClass="details"
        CausesValidation="True" 
        CommandName="Update" 
        Text="Update"
        OnClientClick="javascript:alert('Succesfully updated');"></asp:Button>

Maybe I don't understand the question but a client click handler will be expecting a boolean result to determine if it should execute the post back. You are returning a string value which won't do anything at all.

What are you expecting to occur?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM