.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
页面无刷新的PostBack事件

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

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>");

      }

    }


相关文章

相关软件