what I have is a parent window and modal
I am trying to close the modal by a programatic click of cmd button with js
tried to it
public class frmAuthor : System.Web.UI.Page
{
//parent form with field for data entry has upload button,
//user clicks upload button first client script opens modal window
//user action in modal window causes the close of the modal window
//execution returns to parent in the CmdUpload button onclick event.
//this side is all good
protected void AddClientScript()
{
const string scriptName = "CALL_POPUP";
StringBuilder sb = new StringBuilder("");
sb.Append("\n<script language =\"javascript\">");
sb.Append("\nfunction getData(checkBoxListId)");
sb.Append("\n{");
sb.Append("\nvar mystr = window.showModalDialog('PopFrame.aspx');");
sb.Append("\n}");
sb.Append("\n</script>");
if(!IsClientScriptBlockRegistered(scriptName))
RegisterClientScriptBlock(scriptName,sb.ToString());
}
private void Page_Load(object sender, System.EventArgs e)
{
AddClientScript();
CmdUpload.Attributes["onClick"] = "getData('checkBoxListTest')";
}
private void InitializeComponent()
{
this.CmdUpload.Click += new System.EventHandler(this.CmdUpload_Click);
}
private void CmdUpload_Click(object sender, EventArgs e)
{
try {
//code to upload form data
}
}
}
the modal
public class frmAttach : System.Web.UI.Page
{ //modal window is opened in iframe
//form has fields and 2 buttons, one is CmdUpload where data is processed
//after processing I want to programmatically invoke click of the cmdClose
//to call the javascript which closes the window.
//manually clicking the button works I want to automate this.
private void Page_Load(object sender, System.EventArgs e)
{ AddClientScript(); }
private void InitializeComponent()
{ CmdUpload.Click += new System.EventHandler(this.CmdUpload_Click);}
protected void AddClientScript()
{
string scriptName = "FIND_SELECTED_ITEM";
StringBuilder sb = new StringBuilder("");
sb.Append("\n<script language=\"javascript\">");
sb.Append("\nfunction Item_Selected()");
sb.Append("\n{");
sb.Append("\nwindow.close();");
sb.Append("\n}");
sb.Append("\n</script>");
if(!IsClientScriptBlockRegistered(scriptName))
RegisterClientScriptBlock(scriptName,sb.ToString());
CmdClose.Attributes["OnClick"] = "Item_Selected();return false;";
}
private void CmdUpload_Click(object sender, EventArgs e)
{
//code to upload form data
//in this forum there is a thread on programmatically
//invoking the onclick method and they say to use code below
//but it does not compile for me I get no definition for InvokeOnClick
//this is not compact application
this.InvokeOnClick(this.CmdClose, EventArgs.Empty);
}
}
}
--
cindy
[quoted text, click to view] "Stoitcho Goutsev (100)" wrote:
> cindy,
>
> InvokeOnClick is defined as protected methods on the level of the control
> and is available on .NET1.x also.
>
> Check your spelling and make sure that the class you are calling the method
> derives from Control; Form does derive from this class so you shouldn't have
> problems.
> Keep also in mind that this method is not supported by compact framework. If
> you use CF you need to find out another way of doing it.
>
>
> "cindy" <cmello@nospam.nospam> wrote in message
> news:F9EE1F91-AA8B-4406-A092-ECA316E41A42@microsoft.com...
> > When I compile the error is that form does not contain a definition for
> > this.InvokeOnClick(button1, EventArgs.Empty);
> > is this version 2.0 how is it done in 1.1??
> >
> > --
> > cindy
> >
> >
> > "Oleg Subachev" wrote:
> >
> >> > There is Control.InvokeOnClick event that is also protected that you
> >> > can
> >> > call to invoke the OnClick event on any other control as long as you
> >> > have
> >> > reference to it.
> >>
> >> Thanks.
> >> But what if I need to invoke another event ?
> >>
> >> Oleg Subachev
> >>
> >>
> >>
>
>