Как исправить имя не существует в контексте - PullRequest
0 голосов
/ 27 января 2019

У меня есть код для создания адаптивной таблицы с добавлением и удалением модального всплывающего окна, когда я нажимаю кнопку «Добавить», но что-то отсутствует, и я не знаю, что это. Кто-нибудь может мне помочь с этим?

<%--mpeAddUpdateEmployee Modal Popup Extender For pnlAddUpdateEmployeeDetails--%>
            <uc:modalpopupextender id="mpeAddUpdateEmployee" runat="server" popupcontrolid="pnlAddUpdateEmployeeDetails"
                targetcontrolid="lnkFake" behaviorid="mpeAddUpdateEmployee" cancelcontrolid="btnCancel"
                backgroundcssclass="modalBackground">
        </uc:modalpopupextender>

        <%--lnkFake1 Link Button for mpeDeleteEmployee ModalPopup as TargetControlID--%>
        <asp:LinkButton ID="lnkFake1" runat="server"></asp:LinkButton>

        <%--pnlDeleteEmployee Panel With Design--%>
        <asp:Panel ID="pnlDeleteEmployee" runat="server" CssClass="modalPopup" Style="display: none;">
            <div id="Div1" runat="server" class="header">
            </div>
            <div style="overflow-y: auto; overflow-x: hidden; max-height: 450px;">
                <div class="form-group modal-body">
                    <div class="row">
                        <div class="col-md-12">
                            Do you Want to delete this record ?
                        </div>
                    </div>
                </div>
            </div>
            <div align="right" class="modal-footer">
                <div class="row">
                    <div class="col-md-12">
                        <asp:HiddenField ID="hfDeleteEmployeeId" runat="server" Value="0" />
                        <asp:Button ID="btnYes" runat="server" Text="Yes" OnClick="Yes" class="btn btn-danger">
                        </asp:Button>
                        <button id="btnNo" runat="server" class="btn btn-default">
                            Cancel
                        </button>
                    </div>
                </div>
            </div>
        </asp:Panel>

       <%-- mpeDeleteEmployee Modal Popup Extender For pnlDeleteEmployee--%>
        <uc:ModalPopupExtender ID="mpeDeleteEmployee" runat="server" PopupControlID="pnlDeleteEmployee"
            TargetControlID="lnkFake1" BehaviorID="mpeDeleteEmployee" CancelControlID="btnNo"
            BackgroundCssClass="modalBackground">
        </uc:ModalPopupExtender>

C # КОД ЗДЕСЬ

protected void Edit(object sender, EventArgs e)
            {
                /* Change label text of lblHeading on Edit button 
Click */
                lblHeading.Text = "Update Employee Details";

                /* Sets CommandArgument value to hidden field 
hfAddEditEmployeeId */
                hfAddEditEmployeeId.Value = (sender as 
Button).CommandArgument;

                /* Sets value from Grid cell to textboxes 
txtName,txtCountry and txtSalary */
                txtName.Text = ((sender as Button).NamingContainer as 
GridViewRow).Cells[1].Text;
                txtCountry.Text = ((sender as Button).NamingContainer 
as GridViewRow).Cells[2].Text;
                txtSalary.Text = ((sender as Button).NamingContainer 
as GridViewRow).Cells[3].Text;

                /* Change text of button as Update*/
                btnSave.Text = "Update";

                /* Apply Bootstrap Collapse and Expand Class for Grid 
cells attribute */
                BootstrapCollapsExpand();

                /* Show AddUpdateEmployee Modal Popup */
                mpeAddUpdateEmployee.Show();
            }

            /*Add Employee Detail*/
            protected void Add(object sender, EventArgs e)
            {
                /* Clear Controls Value */
                ClearControls();

                /* Apply Bootstrap Collapse and Expand Class for Grid cells attribute */
                BootstrapCollapsExpand();

                /* Show mpeAddUpdateEmployee Modal Popup */
                mpeAddUpdateEmployee.Show();
            }

            /* Save or Update Employee Details*/
            protected void Save(object sender, EventArgs e)
            {
                /* Code For INSERT OR UPDATE */
                string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
                SqlConnection con = new SqlConnection(constr);

                /* Set employeeId from hfAddEditEmployeeId value for INSERT or UPDATE */
                int employeeId = Convert.ToInt32(hfAddEditEmployeeId.Value);

                string query = string.Empty;
                /* To Check Employee Id For Insert or Update and sets query string variable text*/
                if (employeeId > 0)
                {
                    query = "UPDATE Employee SET Name = @Name, Country = @Country, Salary = @Salary WHERE Id = @Id";
                }
                else
                {
                    query = "INSERT INTO Employee(Name, Country, Salary) VALUES(@Name, @Country, @Salary)";
                }

                SqlCommand cmd = new SqlCommand(query);

                if (employeeId > 0)
                {
                    cmd.Parameters.AddWithValue("@Id", employeeId);
                }
                cmd.Parameters.AddWithValue("@Name", txtName.Text.Trim());
                cmd.Parameters.AddWithValue("@Country", txtCountry.Text.Trim());
                cmd.Parameters.AddWithValue("@Salary", txtSalary.Text);
                cmd.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();

                /* Bind Employee Grid*/
                BindEmployee();

                /* Hide mpeAddUpdateEmployee Modal Popup */
                mpeAddUpdateEmployee.Hide();

                /* Clear Controls Value */
                ClearControls();
            }

            /* Delete Emploee Detail*/
            protected void Delete(object sender, EventArgs e)
            {
                /* Apply CommandArgument value to hidden field hfDeleteEmployeeId */
                hfDeleteEmployeeId.Value = (sender as Button).CommandArgument;

                /* Apply Bootstrap Collapse and Expand Class for Grid cells attribute*/
                BootstrapCollapsExpand();

                /* Show DeleteEmployee Modal Popup */
                mpeDeleteEmployee.Show();
            }

            /* If Select Yes on Delete Modal Popup */
            protected void Yes(object sender, EventArgs e)
            {
                /* Code to Delete Employee Record */
                string constr = ConfigurationManager.ConnectionStrings["constr"].ConnectionString;
                SqlConnection con = new SqlConnection(constr);
                int EmployeeId = Convert.ToInt32(hfDeleteEmployeeId.Value);
                SqlCommand cmd = new SqlCommand("DELETE FROM Employee WHERE Id = @Id");
                cmd.Parameters.AddWithValue("@Id", EmployeeId);
                cmd.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
                con.Close();

                /* Bind Grid Again To see latest Records*/
                BindEmployee();

                /* Hide Delete Employee Modal Popup */
                mpeDeleteEmployee.Hide();

                /*Clear Controls Value*/
                ClearControls();
            }

uc в конструкторе не распознается как префикс тега или устройство.
mpeAddUpdateEmployee.hide () не существует в текущем контексте
mpeAddUpdateEmployee.show () не существует в текущем контексте

Пожалуйста, помогите мне исправить эти ошибки.

...