使用弹出控件扩展器时出现问题! [英] Problem using popup control extender!
本文介绍了使用弹出控件扩展器时出现问题!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好,
我正在使用弹出控件扩展器,以从网格视图中显示带有扩展详细信息的弹出窗口.现在,每当我将鼠标悬停在网格的选择按钮上时,都会弹出一条消息,"Web服务调用失败:500" .
我没有找到解决此问题的任何方法,请帮助我!
在此先感谢!
阿三
Hi All,
I am using a pop control extender to show a popup with extended details from a grid view. Now whenever i do mouseover on the select button of my grid, a message would popup, "Web service call failed:500".
I am not finding any solution for this problem, please help me!
Thanks in Advance!
Ahsan
My code is:
using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using AjaxControlToolkit;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
LoadData();
}
}
private void LoadData()
{
string constr = "Server=Ahsan-PC;Database=SampleDatabase;INtegrated Security = true;";
string query = "SELECT ProductID, ProductName FROM Products";
SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataTable table = new DataTable();
da.Fill(table);
GridView1.DataSource = table;
GridView1.DataBind();
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
PopupControlExtender pce = e.Row.FindControl("PopupControlExtender1") as PopupControlExtender;
string behaviorID = "pce_" + e.Row.RowIndex;
pce.BehaviorID = behaviorID;
Image img = (Image)e.Row.FindControl("Image1");
string OnMouseOverScript = string.Format("$find('{0}').showPopup();", behaviorID);
string OnMouseOutScript = string.Format("$find('{0}').hidePopup();", behaviorID);
img.Attributes.Add("onmouseover", OnMouseOverScript);
img.Attributes.Add("onmouseout", OnMouseOutScript);
}
}
[System.Web.Services.WebMethodAttribute(),
System.Web.Script.Services.ScriptMethodAttribute()]
public static string GetDynamicContent(string contextKey)
{
string constr = "Server=Ahsan-PC;Database=SampleDatabase;";
string query = "SELECT UnitPrice, UnitsInStock, Description FROM Products WHERE ProductID = '"+contextKey+"'";
SqlDataAdapter da = new SqlDataAdapter(query, constr);
DataTable table = new DataTable();
da.Fill(table);
StringBuilder b = new StringBuilder();
b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; ");
b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>");
b.Append("<tr><td colspan='3' style='background-color:#336699; color:white;'>");
b.Append("<b>Product Details</b>"); b.Append("</td></tr>");
b.Append("<tr><td style='width:80px;'><b>Unit Price</b></td>");
b.Append("<td style='width:80px;'><b>Stock</b></td>");
b.Append("<td><b>Description</b></td></tr>");
b.Append("<tr>");
b.Append("<td>$" + table.Rows[0]["UnitPrice"].ToString() + "</td>");
b.Append("<td>" + table.Rows[0]["UnitsInStock"].ToString() + "</td>");
b.Append("<td>" + table.Rows[0]["Description"].ToString() + "</td>");
b.Append("</tr>");
b.Append("</table>");
return b.ToString();
}
}
推荐答案
find('{0}').showPopup();,behaviorID); 字符串OnMouseOutScript = string.Format("
find('{0}').showPopup();", behaviorID); string OnMouseOutScript = string.Format("
find('{0}').hidePopup();",behaviorID); img.Attributes.Add("onmouseover",OnMouseOverScript); img.Attributes.Add("onmouseout",OnMouseOutScript); } } [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] 公共静态字符串GetDynamicContent(string contextKey) { 字符串constr ="Server = Ahsan-PC; Database = SampleDatabase;"; 字符串查询="SELECT单价,UnitsInStock,产品描述,其中ProductID ='" + contextKey +'"; SqlDataAdapter da =新的SqlDataAdapter(query,constr); DataTable表=新的DataTable(); da.Fill(表); StringBuilder b =新的StringBuilder(); b.Append("表 样式 =' background-color:#f3f3f3;边框: #336699 3px实心;); b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing =' 0' 单元填充 =' 3' > ); b.Append(" tr < td colspan =' 3' 样式 背景-color:#336699; color:white;' > ); b.Append(" b < /b > ); b.Append("/td < /tr > ); b.Append(" tr < td 样式 =' width:80px;' > < b < > /td td 样式 =' width:80px;' > < b > 股票< /b > < /td td < b > 描述< /b > < /td > /tr tr td
find('{0}').hidePopup();", behaviorID); img.Attributes.Add("onmouseover", OnMouseOverScript); img.Attributes.Add("onmouseout", OnMouseOutScript); } } [System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string GetDynamicContent(string contextKey) { string constr = "Server=Ahsan-PC;Database=SampleDatabase;"; string query = "SELECT UnitPrice, UnitsInStock, Description FROM Products WHERE ProductID = '"+contextKey+"'"; SqlDataAdapter da = new SqlDataAdapter(query, constr); DataTable table = new DataTable(); da.Fill(table); StringBuilder b = new StringBuilder(); b.Append("<table style='background-color:#f3f3f3; border: #336699 3px solid; "); b.Append("width:350px; font-size:10pt; font-family:Verdana;' cellspacing='0' cellpadding='3'>"); b.Append("<tr><td colspan='3' style='background-color:#336699; color:white;'>"); b.Append("<b>Product Details</b>"); b.Append("</td></tr>"); b.Append("<tr><td style='width:80px;'><b>Unit Price</b></td>"); b.Append("<td style='width:80px;'><b>Stock</b></td>"); b.Append("<td><b>Description</b></td></tr>"); b.Append("<tr>"); b.Append("<td>
"+ table.Rows [0] [" UnitPrice].ToString()+" < /td > ); b.Append(" td < /td > ); b.Append(" td < /td > ); b.Append("/tr /table
" + table.Rows[0]["UnitPrice"].ToString() + "</td>"); b.Append("<td>" + table.Rows[0]["UnitsInStock"].ToString() + "</td>"); b.Append("<td>" + table.Rows[0]["Description"].ToString() + "</td>"); b.Append("</tr>"); b.Append("</table>"); return b.ToString(); } }
这篇关于使用弹出控件扩展器时出现问题!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文