单击gridview的编辑按钮后,btnSaveClass.text
文本按预期更改,但另一方面,btnSave.text
文本未更改
我已经调试了部分代码。并发现此行中包含更改后的文本btnSave.InnerText = "Update";
。但是有一些如何释放数据的。以及它如何变得与以前一样。
//==========================================================This is The Markup=============================
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div class="col-md-4 col-sm-4 col-xs-12 form-group item margin">
<input type="text" class="form-control has-feedback-left" id="txtFName" maxlength="20" onkeypress="return isNameKey(event,this)" required="required" runat="server" placeholder="First Name" />
<span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
</div>
<div class="col-md-4 col-sm-4 col-xs-12 form-group item margin">
<input type="text" class="form-control has-feedback-left" id="txtLName" onkeypress="return isNameKey(event,this)" required="required" runat="server" maxlength="20" placeholder="Last Name" />
<span class="fa fa-user form-control-feedback left" aria-hidden="true"></span>
</div>
<div class="col-md-4 col-sm-4 col-xs-12 form-group item margin">
<input type="text" class="form-control has-feedback-left" id="txtConNumber" onkeypress="return isNumberKey(event,this)" maxlength="11" required="required" runat="server" placeholder="Contact Number" />
<span class="fa fa-mobile form-control-feedback left" aria-hidden="true"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div class="ln_solid"></div>
<div class="form-group ">
<div class="col-md-6 margin ">
//===================================================This button text not changing======================
<button type="button" id="btnSave" runat="server" class="btn btn-success" onserverclick="btnSaveOnClick">Save</button>
<button id="Button2" runat="server" type="button" class="btn btn-primary" onserverclick="btnRefreshOnClick">Refresh</button>
</div>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item">
<asp:TextBox ID="txtRegInfo" required="required" CssClass="form-control has-feedback-left" placeholder="Student Official Id" MaxLength="50" runat="server"></asp:TextBox>
<span class="fa fa-registered form-control-feedback left" aria-hidden="true"></span>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item " style="position: relative;">
<asp:UpdatePanel ID="UpdatePa" runat="server">
<ContentTemplate>
<div class="col-md-12 col-sm-12 col-xs-12 form-group item" style="margin: 0px; padding: 0px;" id="DivddlClassName" runat="server">
<asp:DropDownList ID="ddlClassName" runat="server" CssClass="col-md-12 form-control item has-feedback-left" AutoPostBack="true" OnSelectedIndexChanged="ddlClassNameOnSelectedIndexChanged">
</asp:DropDownList>
<span class="fa fa-tasks form-control-feedback left" aria-hidden="true"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item">
<asp:TextBox ID="txtClassRoll" required="required" onkeypress="return isNumberKey(event,this)" MaxLength="5" CssClass="form-control has-feedback-left" placeholder="Class Roll" runat="server"></asp:TextBox>
<span class="fa fa-star form-control-feedback left" aria-hidden="true"></span>
</div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item">
<asp:UpdatePanel ID="UpdatePanel3" runat="server">
<ContentTemplate>
<div class="col-md-12 col-sm-12 col-xs-12 form-group item" style="margin: 0px; padding: 0px;" id="ddlSectionDiv" runat="server">
<asp:DropDownList ID="ddlSection" runat="server" CssClass="col-md-12 form-control item has-feedback-left" AutoPostBack="true">
<asp:ListItem Value="0" Text="Select A Section"></asp:ListItem>
<asp:ListItem Value="1" Text="A"></asp:ListItem>
<asp:ListItem Value="2" Text="B"></asp:ListItem>
<asp:ListItem Value="3" Text="C"></asp:ListItem>
<asp:ListItem Value="4" Text="D"></asp:ListItem>
<asp:ListItem Value="5" Text="E"></asp:ListItem>
<asp:ListItem Value="6" Text="F"></asp:ListItem>
</asp:DropDownList>
<span class="fa fa-list-alt form-control-feedback left" aria-hidden="true"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<div class="clearfix"></div>
<div class="col-md-3 col-sm-3 col-xs-12 form-group item">
<asp:UpdatePanel ID="UpdatePanel4" runat="server">
<ContentTemplate>
<div class="col-md-12 col-sm-12 col-xs-12 form-group item" style="margin: 0px; padding: 0px;" id="ddlShiftNameDiv" runat="server">
<asp:DropDownList ID="ddlShiftName" runat="server" CssClass="col-md-12 form-control item has-feedback-left" AutoPostBack="true">
<asp:ListItem Value="0" Text="Select A Shift"></asp:ListItem>
<asp:ListItem Value="1" Text="Morning"></asp:ListItem>
<asp:ListItem Value="2" Text="Day"></asp:ListItem>
<asp:ListItem Value="3" Text="Evening"></asp:ListItem>
</asp:DropDownList>
<span class="fa fa-list-alt form-control-feedback left" aria-hidden="true"></span>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<div class="form-group ">
<div class="col-md-6 ">
//==========================================================================This button text changed as expected==============================================
<button type="button" data-target="#myModal" class="btn btn-success" id="btnSaveClass" runat="server" onserverclick="btnSaveClassInfoOnClick">Save</button>
<button id="btn" runat="server" type="button" class="btn btn-primary" onserverclick="btnRefreshOnClick">Refresh</button>
</div>
</div>
//========================================================================This is the gridview===============================
<asp:UpdatePanel ID="UpdatePanel5" runat="server">
<ContentTemplate>
<div class="col-md-12 text-center" style="padding: 10px; background-color: red; color: white; font-weight: bold" id="lblMsg" runat="server" visible="false">One Row has Deleted</div>
<asp:GridView ID="GvStudentIformation" runat="server" Width="100%" CssClass="table table-striped table-bordered table-hover jambo_table bulk_action"
AutoGenerateColumns="False" DataKeyNames="StdntID" AllowPaging="True" OnPageIndexChanging="GvStudentIformationOnPageIndexChanged"
OnRowDeleting="GvStudentInfoOnRowDeleting" OnSelectedIndexChanged="GvStudentInfoOnSelectedIndexChanged">
<HeaderStyle HorizontalAlign="Center" ForeColor="White" BackColor="#3F5367"></HeaderStyle>
<RowStyle CssClass="even pointer " HorizontalAlign="Center" BackColor="#E9F4F2"></RowStyle>
<Columns>
<asp:BoundField DataField="RegistrationNo" ItemStyle-HorizontalAlign="Center" HeaderText="Registration No"></asp:BoundField>
<asp:BoundField DataField="FullName" ItemStyle-HorizontalAlign="Center" HeaderText="Name"></asp:BoundField>
<asp:BoundField DataField="StdntID" HeaderText="Student Class Id">
<ItemStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
</asp:BoundField>
<asp:BoundField DataField="FirstName" HeaderText="First Name">
<ItemStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
</asp:BoundField>
<asp:BoundField DataField="LastName" HeaderText="Last Name">
<ItemStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
</asp:BoundField>
<asp:BoundField DataField="StdntClassID" HeaderText="Student Class Id">
<ItemStyle CssClass="hidden" />
<HeaderStyle CssClass="hidden" />
</asp:BoundField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Delete">
<ItemTemplate>
<asp:LinkButton ID="ButtonDelete" runat="server" CausesValidation="False" CommandName="Delete"><img src="../../images/delete.png" /></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField HeaderText="Edit" ShowSelectButton="true" ButtonType="Image" SelectImageUrl="~/images/Edit.png" ItemStyle-Height="5px" ItemStyle-HorizontalAlign="Center"></asp:CommandField>
<asp:TemplateField ItemStyle-HorizontalAlign="Center" HeaderText="Details">
<ItemTemplate>
<asp:HyperLink ID="btnDetails" runat="server" CausesValidation="False" ForeColor="black" NavigateUrl='<%# String.Format("../Admission/StudentDetails.aspx?StdntID={0}&StdntClassID={1}", Eval("StdntID"), Eval("StdntClassID")) %>'><i class="fa fa-eye"></i> Details</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<SelectedRowStyle BackColor="#CFF0E9" Font-Bold="True" ForeColor="#333333" BorderColor="#1ABC9C" />
<HeaderStyle BackColor="#3F5367" Font-Bold="True" ForeColor="White" HorizontalAlign="Left" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="white" />
<PagerStyle HorizontalAlign="Left" ForeColor="#3F5367" CssClass="gvPagers pad" />
<PagerSettings Mode="NumericFirstLast" PageButtonCount="4" FirstPageText="First" LastPageText="Last" />
<EmptyDataTemplate>
<div class="text-center">No records found.</div>
</EmptyDataTemplate>
</asp:GridView>
<asp:HiddenField ID="HdfstdId" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
//===========Here is the problem, First button text not changing but Second Button Text Changes as Expected=================
protected void GvStudentInfoOnSelectedIndexChanged(object sender, EventArgs e)
{
string id = GvStudentIformation.SelectedRow.Cells[0].Text.Trim().Replace(" ", "");
HdfstdId.Value = id;
txtFName.Value = GvStudentIformation.SelectedRow.Cells[3].Text.Trim().Replace(" ", "");
txtLName.Value = GvStudentIformation.SelectedRow.Cells[4].Text.Trim().Replace(" ", "");
btnSave.InnerText = "Update";
btnSaveClass.InnerText = "Update";
}
答案 0 :(得分:0)
我确实使用脚本来更改按钮文本。这就解决了问题。
function ButtonTextChange() {
document.getElementById('<%=btnInfoSave.ClientID %>').innerText = "Update";
}
在这里,我称其为功能。
ScriptManager.RegisterStartupScript(this, this.GetType(), "CallMyFunction", "ButtonTextChange();", true);