【发布时间】:2014-10-15 20:13:56
【问题描述】:
我正在使用Jquery Dialog,消息长度太大。我正在使用以下代码
JavaScript
function ShowPopup(message) {
$(function () {
$("#dialog").html(message);
$("#dialog").dialog({
title: "New words result",
resizable: true,
height: "auto",
width:"900px",
buttons: {
},
modal: true
});
});
};
C#
string sqlconn = ConfigurationManager.AppSettings["vConnString"].ToString();
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection(sqlconn);
string QUERY = "Sproc_FindNewWords";
SqlCommand cmd = new SqlCommand(QUERY, con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@AM_AssetID", ddlGroup.SelectedItem.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
StringBuilder sb = new StringBuilder();
if (dt.Rows.Count > 0)
{
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i]["val"].ToString()!="")
{
sb.Append("<span>" + dt.Rows[i]["val"].ToString() + "</span>, ");
}
}
}
string message = sb.ToString();
ScriptManager.RegisterStartupScript(this,GetType(), "Popup", "ShowPopup('" + message + "');", true);
我想知道$("#dialog").html(message);的确切长度是多少
当消息文本很小时,它可以正常工作,而当文本太大时,它就无法正常工作。
或
在Jquery Dialog 上显示结果的任何其他方式请提出建议。
【问题讨论】:
-
你可以通过
console.log(message.length);来检查消息的长度。使用 Web 服务时可能会出现长度消息。您使用的是 Web 服务吗? -
不,我在
Button_Click事件上调用函数 -
你试过这个 - roam.be/notebook/2012/…,在 Jquery 对话框中换行,或者在宽度上使用
auto而不是900px。
标签: c# jquery asp.net jquery-dialog