locked
Edit Button not working RRS feed

  • Question

  • User-1499457942 posted

    Hi

      I have below code but it is not going in rowCommand.  It is going in Save_Click method . When i comment below red color lines then it works.

    IN debug it is showing like this

    <a id="btnEdit" title="Update Record" class="clslnkbutton" href="javascript:__doPostBack('ctl00$MainContentPlaceHolder$gvwDSR$ctl02$btnEdit','')"></a>

    When i comment below lines then it workd

    $('[id*=frmMain]').bootstrapValidator({
     container: '#messages',
     feedbackIcons: {
     valid: 'glyphicon glyphicon-ok',
     invalid: 'glyphicon glyphicon-remove',
     validating: 'glyphicon glyphicon-refresh'
     }
    });

    protected void gvw_RowCommand(object sender, GridViewCommandEventArgs e)
            {
                if (e.CommandName == "EditRow")
                {
                    GridViewRow row = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
                    HiddenField hdf_Id0 = (row.FindControl("hdfNo") as HiddenField);
                    hdfId.Value = hdf_Id0.Value;
    
                }
            }
    
    <div class="btn-group" role="group">
    <asp:Button ID="btnSave" CssClass="btn btn-primary" runat="server" class="btn btn-primary" Text=" Update " OnClick="Save_Click"></asp:Button>
    </div> <asp:GridView ID="gvw" OnPreRender="gvwDSR_PreRender" runat="server" CssClass="table table-bordered table-striped" AutoGenerateColumns="false" ClientIDMode="Static" BorderWidth="1px" OnRowDataBound ="gvw_RowDataBound" OnRowCommand="gvw_RowCommand" > <asp:TemplateField HeaderText="Action"> <ItemTemplate> <asp:linkbutton id="btnEdit" ToolTip="Update Record" CommandName="EditRow" runat="server" CssClass="clslnkbutton"/> <asp:linkbutton id="lnkBtnDelete" ToolTip="Delete Record" runat="server" CssClass="clslnkDelbutton" OnClientClick="return confirm('Are you sure you want to delete this item?');" OnClick="lnkBtnDelete_Click" /> </ItemTemplate> </asp:TemplateField>

    Thanks

    Thursday, August 23, 2018 4:06 PM

Answers

  • User-893317190 posted

    Hi JagjitSingh ,

    <a id="btnEdit" title="Update Record" class="clslnkbutton" href="javascript:__doPostBack('ctl00$MainContentPlaceHolder$gvwDSR$ctl02$btnEdit','')"></a>

    Because the href property's content is js code, when you click the a tag, the js code will run. The is to say there is a function named _doPostBack in your page.

    If you open F12 developer tool , you could see the function

     

    You could find in the function the form is submitted . Form submitted in this way will not be intercepted by the bootstrap validator.

    You button btnSave will be rendered as  an input whose type is submit and it will be intercepted by the bootstrap validator.

    Could you tell us what you want to do ? Your description "it works" is not so specific.

    Best regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 24, 2018 7:15 AM

All replies

  • User-893317190 posted

    Hi JagjitSingh ,

    <a id="btnEdit" title="Update Record" class="clslnkbutton" href="javascript:__doPostBack('ctl00$MainContentPlaceHolder$gvwDSR$ctl02$btnEdit','')"></a>

    Because the href property's content is js code, when you click the a tag, the js code will run. The is to say there is a function named _doPostBack in your page.

    If you open F12 developer tool , you could see the function

     

    You could find in the function the form is submitted . Form submitted in this way will not be intercepted by the bootstrap validator.

    You button btnSave will be rendered as  an input whose type is submit and it will be intercepted by the bootstrap validator.

    Could you tell us what you want to do ? Your description "it works" is not so specific.

    Best regards,

    Ackerly Xu

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 24, 2018 7:15 AM
  • User-1499457942 posted

    Hi

      I have put this issue in Web Forms Now. Can u pls check it there . I have made some changes in code.

    Thanks

    Friday, August 24, 2018 7:20 AM