[RESOLVED]How to pseudo click Update link button from javascript


How can I click a Formview Update link button from javascript ?

Hi shtrudel,

From your description, if you want to add client event for update button, you could refer to the following code.

    <script type="text/javascript">
        function updateClick() {
            return false;

        <asp:FormView ID="FormView1" runat="server" DataKeyNames="Id" DataSourceID="SqlDataSource1" OnItemUpdating="FormView1_ItemUpdating" DefaultMode="Edit">
                <asp:Label ID="IdLabel1" runat="server" Text='<%# Eval("Id") %>' />
                <br />
                Name :
                <asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
                <br />
                Gender :
                <asp:TextBox ID="GenderTextBox" runat="server" Text='<%# Bind("Gender") %>' />
                <br />
                <asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True" OnClientClick="return updateClick();" CommandName="Update" Text="Update" />
                &nbsp;<asp:LinkButton ID="UpdateCancelButton" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel" />


If you want to trigger update button click event from JavaScript. You could refer to the following code.

document.getElementById('<%= FormView1.FindControl("UpdateButton").ClientID %>').click()

If you have any other questions about my reply, please let me know freely.

Best Regards,

Leave a Reply