Thursday, 15 September 2011

Opening a Popup window in asp.net and process it and then refreshing the parent window by closing child window using javascript in asp.net


Parent p.aspx page aspx code:

<script language="javascript" type="text/javascript">
function divert(pkvalue)
{
    var strUrl = "c.aspx?pkvalue="+pkvalue;
    window.open(strUrl, '', 'status=1,scrollbars=1,width=280,height=180');
}
function CallParentFunction()
{

   //window.location.href ="p.aspx";
   window.location.reload();    //Anything will work

}
</script>

<body><form id="form1" runat="server"><div>
<a id="edit1" onclick="javascript:divert(this.id);">Edit1</a>
</div></form></body>

Child c.aspx page aspx.cs code:
protected void Page_Load(object sender, EventArgs e)
{
    string s= Request.QueryString["pkvalue"].ToString();
    lblmsg.Text = "pkvalue:" + s;
    //var s having pkvalue so you can show what to update
}
protected void btnSave_Click(object sender, EventArgs e)
{
    //process saving your data
    ScriptManager.RegisterStartupScript(this, this.GetType(), "calling parent", "javascript:window.close();", true);
}


Child c.aspx page aspx code:
<body onunload="window.opener.CallParentFunction();">
<form id="form1" runat="server">
<div>
<asp:Label ID="lblmsg" runat="server" ></asp:Label>
<br /><asp:Button ID="btnSave" runat="server" Text="Save & Close" onclick="btnSave_Click" />
</div>
</form>
</body>

Tag: Opening a Popup using javscript, Opening a Popup window in asp.net, Refreshing parent window in asp.net, Refreshing parent window in asp.net using javascript, Refreshing parent window using Javascript

No comments:

Post a Comment

Parsing JSON w/ @ symbol in it

To read the json response like bellow @ concatenated with attribute                             '{ "@id": 1001, "@name&q...