欢迎光临
我们一直在努力

页面无刷新的PostBack事件-.NET教程,评论及其它

建站超值云服务器,限时71元/月

textbox的onchange事件会引起页面重新刷新,这使得输入很不方便,于是我想了以下的解决办法。

思路:1、调用简单的前台脚本打开一个新页, 2、把相关参数传递给该新页处理(该新页的前后台均可处理), 3、处理后所得数据再用前台脚本返回opener, 4、数据处理完毕后被打开的页面自动关闭。代码例:要处理的页面send.aspx:

string windowattribs = "width=10px," + "height=10px," + "left=+((screen.width +" + "10" + ") * 2)+," + "top=+ (screen.height + " + "10" + ") * 2+";

textbox2.attributes["onchange"] = "var aaa = this.value;window.open(open_xml.aspx?get_id=textbox2&get_value=+aaa,open_test,"+windowattribs+")";

textbox3.attributes["onchange"] = "var aaa = this.value;window.open(open_page.aspx?get_id=textbox3&get_value=+aaa,open_test,"+windowattribs+")";

打开的页面open_page.aspx:

private void page_load(object sender, system.eventargs e)

{

object ls_o1 = request.querystring["get_id"].tostring();

object ls_o2 = request.querystring["get_value"].tostring();

if(ls_o1 != null && ls_o2 != null)

{

get_id.value = (string)ls_o1;

get_value.value = (string)ls_o2;

}

send_value_back();

}

private void send_value_back()

{

if(get_id.value != "" && get_value.value != null)

{

this.response.write("<script language=javascript>window.opener.form1."+get_id.value+".value=aaaaaaaaaaaa"+"</script>");

this.response.write("<script language=javascript>window.opener=null;window.close();</script>");

}

}

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 页面无刷新的PostBack事件-.NET教程,评论及其它
分享到: 更多 (0)

相关推荐

  • 暂无文章