页面无刷新的PostBack事件

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

      }

    }
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值