AjaxToolkit ModalPopup Extender - PullRequest
       22

AjaxToolkit ModalPopup Extender

0 голосов
/ 29 декабря 2011

Я использую AjaxToolKit и создал сетку с кнопкой Подробности. Я хочу открыть панель, которая будет иметь еще 2 вида сетки при нажатии кнопки «Подробности» как ModalPopupExtender. Следует также выделить строку, которая редактируется. Я получаю эту ошибку ...

Сведения об ошибке веб-страницы Сообщение: недопустимый символ Линия: 269 Чар: 7 Код: 0 URI: http://localhost:5427/ModalPopUpInGridView/Default3.aspx

Я проверил как дизайн / источник, так и код, но не смог найти недопустимых символов. Также, когда я нажимаю на кнопки «Подробности» во время выполнения, вид сетки исчезает.

Есть предложения?

Вот полный исходный код:

HTML Part:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default3.aspx.cs" Inherits="Default3" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>

    <style>
    .modalBackground
    {
    background-color:Gray;
    filter:alpha(opacity=70);
    opacity:0.7;
    }
    </style>
</head>
<body>
    <form id="form1" runat="server">
    <ajaxToolkit:ToolkitScriptManager ID="scriptManager" runat="server" />
<div>
<p style="background-color:AliceBlue; width:95%">
Example of using a
ModalPopupExtender to edit the indivdual rows of a GridView.<br />
To test out the functionality,
click the Details button of any of the rows and watch what happens.<br />
</p>
<br />
<asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblTitle" runat="server" Text="Customers" BackColor="lightblue" Width="95%" />
<asp:GridView
ID="gvCustomers" runat="server"
AutoGenerateColumns="false"
AllowPaging="true" AllowSorting="true"
PageSize=10 OnPageIndexChanging="myGridView_PageIndexChanging"
OnRowDataBound="Gridview_RowDataBound" EnableViewState="false"
Width="95%">
<AlternatingRowStyle BackColor="AliceBlue"
/>
<HeaderStyle HorizontalAlign="Left"
/>
<Columns>

<asp:TemplateField HeaderText="V"> 
<ItemTemplate> 
    <asp:CheckBox ID="chkVerified" runat="server" 
     Checked='<%# Eval("V") == "True" ? true : false  %>'/>
</ItemTemplate> 
</asp:TemplateField> 

<asp:TemplateField HeaderText="NT"> 
<ItemTemplate> 
    <asp:CheckBox ID="chkDeleted" runat="server" />
</ItemTemplate> 
</asp:TemplateField>

<asp:TemplateField HeaderText="P">
<ItemTemplate >
    <asp:Label ID="P" runat="server" Text='<%# Eval("P") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="FN">
<ItemTemplate >
    <asp:Label ID="FN" runat="server" Text='<%# Eval("FN") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="MN" >
<ItemTemplate >
    <asp:Label ID="MN" runat="server" Text='<%# Eval("MN") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="LN" >
<ItemTemplate >
    <asp:Label ID="LN" runat="server" Text='<%# Eval("LN") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>

<asp:TemplateField HeaderText="Title">
<ItemTemplate >
    <asp:Label ID="Title" runat="server" Text='<%# Eval("Title") %>' ></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="btnViewDetails"
runat="server"
Text="Details"
OnClick="btnViewDetails_Click"
/>
</ItemTemplate>
    <ControlStyle Width="50px" />
    <HeaderStyle Width="60px" />
</asp:TemplateField>


</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button id="btnShowPopup" runat="server" style="display:none" />
<ajaxToolKit:ModalPopupExtender
ID="mdlPopup" runat="server" TargetControlID="btnShowPopup" PopupControlID="pnlPopup"
CancelControlID="btnClose" BackgroundCssClass="modalBackground" />
<asp:Panel ID="pnlPopup" runat="server" Width="500px" style="display:none">
<asp:UpdatePanel ID="updPnlCustomerDetail" runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblCustomerDetail" runat="server"
Text="Customer
Detail" BackColor="lightblue" Width="95%" />
<asp:Panel ID="pnlPopupInner" runat="server">
<table>
<tr><td>Test1</td></tr>
<tr><td>Test2</td></tr>
<tr><td>Test3</td></tr>
</table>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
<div align="right" style="width:95%">
<asp:Button
ID="btnSave" runat="server"
Text="Save"
OnClientClick="alert(’Sorry, but I didnt implement save because I
dont want my northwind database getting messed up.’); return false;"
Width="50px" />
<asp:Button ID="btnClose" runat="server" Text="Close" Width="50px" />
</div>
</asp:Panel>
</div>
</form>
</body>
</html>

Код сзади:

using System;
using System.Drawing;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using MDRTeachersTest; //Webservice

public partial class Default3 : System.Web.UI.Page
{
    string sFullName = "";
    int firstRow = 0;
    private int selectedIndex;

    protected void Page_Load(object sender, EventArgs e)
    {
        sFullName = "";
        firstRow = -1;
        if (!IsPostBack)
        {
            bool bTest = loginToWS();
            if (bTest == true)
            {
                gvCustomers.Visible = true;
            }
        }
    }

    private bool loginToWS()
    {
        //code to login to web service and fetch the object filled with data.
    }


    private static DataTable dtInfoPersonnel(Organization org)
    {
        string RowId = "";
        string PersonId = "";
        bool firsttime = true;
        DataRow dr;

        DataTable dtTemp = new DataTable();
        dtTemp.Columns.Add("V", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("NT", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("P");
        dtTemp.Columns.Add("FN");
        dtTemp.Columns.Add("MN");
        dtTemp.Columns.Add("LN");
        dtTemp.Columns.Add("Title");
        dtTemp.Columns.Add("Remove");
        dtTemp.Columns.Add("Vacant", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("Status");
        dtTemp.Columns.Add("RowId");
        dtTemp.Columns.Add("PersonId");
        dtTemp.Columns.Add("Verified", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("Substitute", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("ComputerUser", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("YearsExperience");
        dtTemp.Columns.Add("Closed", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("AP", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("CU", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("PF", System.Boolean.FalseString.GetType());
        dtTemp.Columns.Add("historicAlphaCode");

        foreach (K12Personnel person in org.persons)
        {
            //Code to fill DATATABLE with the data.
        }

        return dtTemp;
    }


    protected void Gridview_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                //e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(gvCustomers, "Select$" + e.Row.RowIndex.ToString()));

                //We're only interested in Rows that contain data
                //get a reference to the data used to databound the row
                DataRowView drv = ((DataRowView)e.Row.DataItem);
                if (sFullName == drv["FN"].ToString() + drv["LN"].ToString())
                {
                    //If it's the same category as the previous one
                    //Increment the rowspan
                    for (int cellCount = 0; cellCount < 6; cellCount++)
                    {
                        if (gvCustomers.Rows[firstRow].Cells[cellCount].RowSpan == 0)
                            gvCustomers.Rows[firstRow].Cells[cellCount].RowSpan = 2;
                        else
                            gvCustomers.Rows[firstRow].Cells[cellCount].RowSpan += 1;
                        //Remove the cell
                        e.Row.Cells.RemoveAt(0);
                    }
                }
                else //It's a new category
                {                //Set the vertical alignment to top
                    e.Row.VerticalAlign = VerticalAlign.Top;
                    //Maintain the category in memory
                    sFullName = drv["FN"].ToString() + drv["LN"].ToString();
                    firstRow = e.Row.RowIndex;
                }
            }


        }
        catch (Exception ex)
        {
        }
    }

    protected void myGridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
    {
        DataTable dtTemp1 = new DataTable();
        dtTemp1 = (DataTable)Session["PersonnelInfo"];
        dtTemp1.DefaultView.Sort = "LN " + "ASC";
        gvCustomers.DataSource = dtTemp1;
        gvCustomers.PageIndex = e.NewPageIndex;
        gvCustomers.DataBind();
    }

    protected void btnViewDetails_Click(object sender, EventArgs e)
    {
        this.updPnlCustomerDetail.Update();
        this.mdlPopup.Show();
    }

Когда я запускаю код. Он отображает сетку, но в левом нижнем углу браузера появляется ошибка «Недопустимый символ». Пейджинг работает, но когда я нажимаю кнопку «Подробности», вся сетка исчезает.

1 Ответ

1 голос
/ 29 декабря 2011

Это может быть из-за этой строки:

OnClientClick="alert(’Sorry, but I didnt implement save because I dont want my northwind database getting messed up.’); return false;"

Вам нужно использовать ' вместо '

Это jsfiddle подтверждает мое подозрение.

...