【发布时间】:2010-09-28 12:19:38
【问题描述】:
所以我正在尝试从 .aspx 页面加载一些返回的 html,但是在执行 AJAX 请求所依赖的某些操作之前,需要触发单击事件。更具体地说,我正在这样做。当用户在文本字段中键入时,此函数将运行...
function KeyPress() {
$("#" + HiddenButtonId).click();
$("#test").load("TempJumpToAJAX.aspx");
}
然后 $("#" + HiddenButtonId).click();确实在代码隐藏文件中设置了一些会话数据。具体...
Session["SearchText"] = Search.Text;
然后,$("#test").load("TempJumpToAJAX.aspx");调用返回新建选择框的 .aspx 页面...
Response.Expires = -1;
StringBuilder builder = new StringBuilder();
builder.Append("<select id=\"testListId\" name=\"testList\" size=\"4\" style=\"width:200px;\">");
builder.Append("<option>");
builder.Append(Session["SearchText"]);
builder.Append("</option>");
builder.Append("</select>");
Response.ContentType = "text/HTML";
Response.Write(builder.ToString());
Response.End();
问题是,订单似乎搞砸了,它首先尝试附加 Session["SearchText"],然后运行 click 事件运行的代码。所以它的功能更像这样......
function KeyPress() {
$("#test").load("TempJumpToAJAX.aspx");
$("#" + HiddenButtonId).click();
}
命令颠倒的地方。所以实际上发生的是会话变量有一个空字符串,而不是用户在文本框中键入的内容。对我来说奇怪的是,它似乎不应该有一个空字符串,它似乎应该什么都没有,因为此时会话变量还没有被初始化为任何东西。我真的不知道发生了什么。我猜这归咎于缺乏经验。有什么想法吗?
【问题讨论】:
标签: c# asp.net javascript jquery ajax