以下是前台的代码
$().ready(function () {
alert(<%=ss %>);
var Org=<%=ss %>;
alert(Org);
以下是后台的代码
public string ss = "";
protected void Page_Load(object sender, EventArgs e)
{
}
protected void txtRP10_SelectedIndexChanged(object sender, EventArgs e)//奖惩类型
{
//奖惩条例文本框模糊查询
if (txtRP10.SelectedItem.Text.Length > 0)
{
string RP10 = txtRP10.SelectedItem.Text;
string str = " PM08 LIKE '%" + RP10 + "%' ";
Maticsoft.BLL.Hrapapm bll2 = new Maticsoft.BLL.Hrapapm();
DataSet ds = bll2.GetList(0, str, "PM03");
StringBuilder sb = new StringBuilder();
sb.Append("[");
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
sb.Append("'" + ds.Tables[0].Rows[i]["PM08"] + "',");
}
ss = sb.ToString().Substring(0, sb.ToString().Length - 1);
ss = ss + "]";
}
}
目前问题是 只有触发了SelectedIndexChanged事件, 才出现 alert(<%=ss %>) 结果,希望的结果是 载入网页的时候 就能alert 出来值.
把txtRP10_SelectedIndexChanged 里面的代码写到一个函数里面 pagelonad 和 txtRP10_SelectedIndexChanged 都分别调一伙这个函数试试~
pageload里面ss没有赋值