看下这句话为什么不执行后台的事件 Submit
protected void Submit(object sender, EventArgs e)
{
//txt_pwd.Attributes.Add("onblur", "Test(this)");
Response.Write("Test");
}
<input id="btn_submit" type="button" value="button" onclick="if(!ajaxsend()){return false;}" runat="server" onserverclick="Submit" />
ajaxsend() 这个方法是前台的
var ajax = null;
function ajaxsend() {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
if (ajax != null) {
ajax.onreadystatechange = Get_Value;
ajax.open("GET", "Test.aspx?id=" + escape(document.getElementById("txt_user").value), true);
ajax.send(null);
}
}
function Get_Value() {
if (ajax.readyState == 4 && ajax.status == 200) {
document.getElementById("sp1").innerHTML = ajax.responseText;
}
}
Test.aspx页面如下:
protected string Id = string.Empty;
protected override void Render(HtmlTextWriter writer)
{
Id = Request["id"] == null ? "" : Request["id"].ToString();
switch (Id)
{
case "1":
Get_Reg1(writer);
break;
case "2":
Get_Reg2(writer);
break;
}
}
void Get_Reg1(HtmlTextWriter writer)
{
string str = "True";
writer.Write(str);
}
慕婉清6462132
手掌心