简体   繁体   English

OnClientClick在Formview asp.net中不起作用

[英]OnClientClick doesnt work in Formview asp.net

I am working in asp.net vb.net. 我正在asp.net vb.net中工作。 I have a datagrid with a update button like this : OnClientClick="return ('Succesfully updated!')"> Which works like a charm. 我有一个带有更新按钮的数据网格,如下所示: OnClientClick="return ('Succesfully updated!')">这就像一个OnClientClick="return ('Succesfully updated!')">按钮。

And I have this one in the formview: 我在formview中有这个:

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

Its exactly the same button as in the gridview, but it doesnt seem to work? 它与gridview中的按钮完全相同,但是似乎不起作用? 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 另一个完全相同,但是具有不同的文本和另一个ID

I think you are try to fire alert() function on client click try this: 我认为您正在尝试在客户端上触发alert()函数,请尝试以下操作:

<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? 您期望发生什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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