Enjoy Life

A Ryan Gene Blog!

Thursday, August 17, 2006

[Code]用JavaScript执行PostBack

早上实现了在子页面更新数据以后,父页面刷新树的功能

思路:



  • 父页面有个隐藏的html button作为proxy,子页面保存完数据以后,用js调用父页面的html button的触发函数click();

  • 父页面有个asp.net的link button控件,text="",等于也是隐藏的,它负责调用后台cs代码里的负责刷新树的方法;

  • 父页面的html button onclick的时候,__doPostBack('DoRefresh','');



代码:



父页面apsx:
<input type="button" id="DoRefreshProxy" value="DO" onclick="__doPostBack('DoRefresh','');" style="display:none;" />

<asp:linkbutton id="DoRefresh" runat="server" onclick="DoRefresh_Click" CausesValidation=False/>

父页面cs:

protected void DoRefresh_Click(object sender, EventArgs e)
{
this.BindTree(this.tvBuilding.SelectedNodeIndex,1);
}

子页面cs:

Page.RegisterStartupScript("pb","<script>window.opener.document.getElementById('DoRefreshProxy').click();</script>");

posted by Ryan Gene at 11:08 AM

0 Comments:

Post a Comment

<< Home

Name:
Location: Shanghai, Shanghai, China

Powered by Blogger
Powered by Writely

Add to Google

Site Feed