By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,600 Members | 1,887 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,600 IT Pros & Developers. It's quick & easy.

Calling Parent form Event from child page

P: 1
I have a parent form and on button click I am calling a child page where i have a textbox and a button. On button click of child form I am passing the value of the Textbox to the Textbox in parent page and now I want to fire an event.

Button click event on parent page- parameter is txtBlank (TextBox in parent page)

Expand|Select|Wrap|Line Numbers
  1. function SetRange(Src)
  2.     {
  3.     window.open("SetRange.aspx?src=" + Src, "_blank", "status = 1, ontop=true, height=110, width=210, left=680, top=280, alwaysRaised = 1 resizable = 0,scrollbars=1", true);           
  4.     //window.opener.document.getElementById("txtBlank).TextChanged();
  5.     }
  6.  
The child page code is ----- Button click event on child page- where txtTopRange is Textbox in child page and Request.QueryString["src"] = txtBlank (TextBox in parent page)

Expand|Select|Wrap|Line Numbers
  1. protected void Button1_Click(object sender, EventArgs e)
  2.         {
  3.  
  4.             System.Text.StringBuilder sbScript = new System.Text.StringBuilder();
  5.             sbScript.Append("<script language='javascript'>");
  6.             sbScript.Append(Environment.NewLine);
  7.             sbScript.Append("window.opener.document.forms[0].");
  8.             sbScript.Append(Request.QueryString["src"]);
  9.             sbScript.Append(".value = '");
  10.             sbScript.Append(txtTopRange.Text);
  11.             sbScript.Append("';");
  12.             sbScript.Append(Environment.NewLine);
  13.  
  14.  
  15.                 //sbScript.Append("window.opener.document.forms[0].");
  16.                 //sbScript.Append(Request.QueryString["src"]);
  17.                 //sbScript.Append(".fireEvent('TextChanged')");
  18.                 //sbScript.Append(";");
  19.                 //sbScript.Append(Environment.NewLine);
  20.  
  21.  
  22.             sbScript.Append("window.close();");
  23.             sbScript.Append(Environment.NewLine);
  24.  
  25.             sbScript.Append("</script>");
  26.             ClientScript.RegisterStartupScript(this.GetType(), "CloseWindow", sbScript.ToString());
  27.         }
  28.  

The commented is where i am trying to call the event TextBox_TextChanged of parent form. The code above the commented one is passing the correct the value to my parent form's textBox.



On debugging the Javascript code is as-

Expand|Select|Wrap|Line Numbers
  1. <script language='javascript'>         working fine
  2. window.opener.document.forms[0].txtBlank.value = '5';      working fine
  3. window.opener.document.forms[0].txtBlank.fireEvent('TextChanged');      not working
  4. </script> 
  5.  
Thanks In advance

Nupur
Jul 10 '08 #1
Share this Question
Share on Google+
1 Reply


acoder
Expert Mod 15k+
P: 16,027
fireEvent is IE-only. Why not just call the function which gets fired onchange?
Jul 10 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.