ASP.net 2.0的回调是否有中文问题,以下的一个无关的DropDownList的Value值发生变化。<asp:DropDownList ID="DropDownList2" runat="server"
AppendDataBoundItems="True">
<asp:ListItem Value="aa">- Select Product -</asp:ListItem>
</asp:DropDownList>
此语句下工作正常
变成
<asp:DropDownList ID="DropDownList2" runat="server"
AppendDataBoundItems="True">
<asp:ListItem Value="好">- Select Product -</asp:ListItem>
</asp:DropDownList>
就工作不正常了,Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");根本就不执行回调,why?以下附部分源码。各位大虾看看,是不是微软VS2005的bug?
AppendDataBoundItems="True">
<asp:ListItem Value="aa">- Select Product -</asp:ListItem>
</asp:DropDownList>
此语句下工作正常
变成
<asp:DropDownList ID="DropDownList2" runat="server"
AppendDataBoundItems="True">
<asp:ListItem Value="好">- Select Product -</asp:ListItem>
</asp:DropDownList>
就工作不正常了,Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");根本就不执行回调,why?以下附部分源码。各位大虾看看,是不是微软VS2005的bug?
解决方案 »
- 一个困扰很久的问题,请教!
- Oracle数据库问题
- 由javascript赋值的控件如何再传值到服务器端
- 网站发布问题??
- ??????(请教高手)如何在Asp.net中实现运行时拖放控件功能?
- 请问上传控件uploadify onUploadStart 没有提交最新参数
- 关于数据库保存上传文件路径问题-高分在线
- 全局变量的问题。
- 还是treeview的问题,如何得到当前选中的node的文件和ID?
- 关于asp.net的quickstar的问题
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 下如何让copyright沉到页面最下面
- 让我很郁闷,也很奇怪,也很简单,也证明我很笨的一个datagrid问题,save me....
<html xmlns="http://www.w3.org/1999/xhtml"> <script type="text/javascript">
function CallServer(arg, context)
{
context.innerHTML = "Loading";
<%= callback %>;
} function ReceiveServerData(result, context)
{
context.innerHTML = result;
}
function RefreshBind()
{
//alert("ok111");
// opener.Form1.TFaZhan.value="tt";
// opener.location="mobile_send.aspx";
Form1.Brefresh.click();
// window.close();
}
function CRefresh(CNO,ctype)
{
//alert("ok111");
switch(ctype)
{
case "TY" : Form1.TTYCNO.value=CNO;
Form1.Btyok.click();
break;
case "SH" : Form1.TSHCNO.value=CNO;
Form1.Bshok.click();
break;
case "FK" : Form1.TFKCNO.value=CNO;
Form1.Bfkok.click();
break;
default: break;
} }
</script><head>
<title>Callback</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="_div1" runat="server">
<asp:DropDownList ID="ddlCategory" runat="server" AppendDataBoundItems="True">
<asp:ListItem Value="">- Select Category -</asp:ListItem>
<asp:ListItem Value="aa">- Select Category -</asp:ListItem>
<asp:ListItem Value="bb">- Select Category -</asp:ListItem>
</asp:DropDownList>
<span id="_span1">
<asp:DropDownList ID="ddlProduct" runat="server"
AppendDataBoundItems="True" Visible=false>
<asp:ListItem Value="好">- Select Product -</asp:ListItem>
</asp:DropDownList>
</span><span id="_span2">
<asp:Button ID="btnBuy" runat="server" Text="Buy" Enabled="false" OnClick="btnBuy_Click" />
<br />
</span>
</div>
<asp:Label ID="Label2" runat="server"></asp:Label>
</div>
<div>
<asp:DropDownList ID="DropDownList2" runat="server"
AppendDataBoundItems="True">
<asp:ListItem Value="aa">- Select Product -</asp:ListItem>
</asp:DropDownList>
</div>
<asp:Label ID="Label1" runat="server">好</asp:Label>
</form>
</body>
</html>
CS文件:
public string callback = "";
protected void Page_Load(object sender, EventArgs e)
{
ddlCategory.Attributes.Add("onchange", "CallServer('FillProduct|'+this.value+'|heqian',_span1)");
ddlProduct.Attributes.Add("onchange", "CallServer('ShowBuy|'+this.value,_span2)");
callback=Page.ClientScript.GetCallbackEventReference(this, "arg", "ReceiveServerData", "context");
if (!Page.IsPostBack)
{
// BindDataDrop();
}
}
#region ICallbackEventHandler Members public string GetCallbackResult()
{
string[] parts = _callbackEventArgument.Split('|');
object[] args = null;
string result = ""; if (parts.Length > 1)
{
args = new object[parts.Length - 1];
Array.Copy(parts, 1, args, 0, args.Length);
} MethodInfo method = this.GetType().GetMethod(parts[0]); if (method != null)
{
result = (string)method.Invoke(this, args);
} return result;
} public void RaiseCallbackEvent(string eventArgument)
{
// _eventArgument = eventArgument;
_callbackEventArgument = eventArgument;
} void ICallbackEventHandler.RaiseCallbackEvent(string eventArgument)
{
this.RaiseCallbackEvent(eventArgument);
} string ICallbackEventHandler.GetCallbackResult()
{
return this.GetCallbackResult();
} #endregion
public string RenderControl(Control control)
{
StringWriter writer1 = new StringWriter(CultureInfo.InvariantCulture);
HtmlTextWriter writer2 = new HtmlTextWriter(writer1); control.RenderControl(writer2);
writer2.Flush();
writer2.Close(); return writer1.ToString();
}
public string FillProduct(string categoryID, string tmp)
{
// ddlCategory.SelectedValue = categoryID;
//ddlProduct.DataBind();
BindUsers(categoryID, tmp);
ddlProduct.Visible = true;
return RenderControl(ddlProduct);
} public string ShowBuy(string ProductID)
{
btnBuy.Enabled = !string.IsNullOrEmpty(ProductID); return RenderControl(btnBuy);
}
protected void btnBuy_Click(object sender, EventArgs e)
{
_div1.Visible = false;
Label1.Text = "Buy: " + Request.Form[ddlProduct.UniqueID];
}