Ajax Popupcontrolextender问题

时间:2011-01-21 09:26:38

标签: ajaxcontroltoolkit

我有一个奇怪的问题。我已按照此处的示例(http://www.4guysfromrolla.com/articles/071107-1.aspx)显示ajax弹出窗口,但它无法正常工作。

我遇到的问题是图像属性设置不正确,我使用Firebug进行了检查,这是我在加载后第1页上的内容。

<img src="StyleSheets/magglass.jpg" id="mainContent_TheGrid_MagGlass_0">

现在奇怪的是,如果我转到第2页,onmouseover事件已针对所有图像正确设置,如果我回到第1页,它也会正确设置,例如。

<img src="StyleSheets/magglass.jpg" onmouseover="$find('pce0').showPopup(); " id="mainContent_TheGrid_MagGlass_0">

我逐步完成了代码,并确认对于每一行

,我的网格都会触发rowcreated事件

任何想法?

我的代码与示例略有不同,见下文

protected void TheGrid_RowCreated(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        // Programmatically reference the PopupControlExtender
        PopupControlExtender pce = e.Row.FindControl("TheGrid_PopupControlExtender") as PopupControlExtender;

        // Set the BehaviorID
        string behaviorID = string.Concat("pce", e.Row.RowIndex);
        pce.BehaviorID = behaviorID;

        // Programmatically reference the Image control
        Image i = (Image)e.Row.Cells[0].FindControl("MagGlass");

        // Add the client-side attributes (onmouseover & onmouseout) 
        string OnMouseOverScript = string.Format("$find('{0}').showPopup(); ", behaviorID);


        i.Attributes.Add("onmouseover", OnMouseOverScript);

    }
}

下面是GetDynamicContent方法,它添加了hidepopup方法。

   [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()]
public static string GetDynamicContent(string contextKey)
{

    GridView MyGrid = (GridView)HttpContext.Current.Session["TheGrid"];

    var MyVar = from GridViewRow MyRow in MyGrid.Rows
                where MyRow.Cells[MyRow.Cells.Count - 1].Text == contextKey
                select MyRow;

    //This is the selected row by the user
    GridViewRow MyGridRow = MyVar.SingleOrDefault();

    //MyGridRow.Cells[3].Text is the log entry.  
    string MyTable = @"<table class=""PopUpTable""><tr><td><textarea class=""textarea"">"
       + MyGridRow.Cells[3].Text + "</textarea></td>";

    //MyGridRow.RowIndex is used to determine the name of popup control for the hidepopup script
    MyTable += "<td><button type=\"button\" class=\"PopUpButton\" onclick=\"$find('pce" + MyGridRow.RowIndex.ToString() + "').hidePopup();\">Close</button></td></tr></table>";

    return MyTable;

}

这是pageIndexChanging事件

  protected void TheGrid_PageIndexChanging(object sender, GridViewPageEventArgs e)
{

    TheGrid.PageIndex = e.NewPageIndex;      

        LoadFromDB();

}

这里的LoadFromDB方法:

private void LoadFromDB()
{
    try
    {
        LOGDBDataContext LDC = new LOGDBDataContext(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString);



        string Query = @"DateTimeStamp >= @0 and DateTimeStamp <= @1"; 


        var Tolo = LDC
                   .Logs
                   .Where(Query, this.FromCalendar.SelectedDate, this.ToCalendar.SelectedDate)
                   .OrderBy("DateTimeStamp desc")
                   .Select("new (LogID, DateTimeStamp, Organization, LogEntry, ServerHostname)");


        TheGrid.DataSource = Tolo;
        TheGrid.DataBind();



    }


    catch (Exception ex)
    {
    //do something here
    }
}

1 个答案:

答案 0 :(得分:0)

没关系,找到了答案。

  1. 调试不佳
  2. 一次糟糕的尝试 清除不是的gridview 由pagechanging事件
  3. 调用

    无能,你的名字是yomismo