Hi,

I have web page containing 4 ImageButtons for get new id,delete a record,edit the record and save a record.The three of them worked correctly.

But when clicking on the save button, a message of microsoft internet exolorer displayed like this:

The Web Page you are Viewing is trying to close the window.

Do you want to close the window?

If I click on 'No', the Save button Works its function. What is the reason for it?

How can i overcome this problem?

Hope you can help me.

Thanks in advance.

Could you please post your Image button source code in .aspx file.
There might be a javascript function which contains a window.close(); statement that is being called on 'OnClientClick' of the Image button. Remove this statement or the whole function call if you dont want it.

Hi,
I never used javascript code in my page.

this is the code in .aspx page:

<td style="width: 55px; height: 19px" valign="top">
                                <asp:ImageButton ID="imgSave" runat="server" ImageUrl="~/basic/save.gif" OnClick="imgSave_Click" /></td>

And I used the code in aspx.cs page is:

int id = Convert.ToInt32(txtCountryid.Text.ToString());
        string name = txtCountryName.Text;            
        country.countnameProc(1, id, name);         
        MsgBox1.alert("ItemSaved");
        txtCountryid.Text = "";
        txtCountryName.Text = "";

Thanks in advance.

I cant see anything on this code snippet. May be your custom control MsgBox1 is corrupt. Can u please remove the statement MsgBox1.alert("ItemSaved"); from the code and replace it with this. Response.Write(@"<script language='javascript'>alert('Item Saved')</script>"); Please let me know the result.

Hi,
I remove the statement MsgBox1.alert("ItemSaved"); from my code and replace it with Response.Write(@"<script language='javascript'>alert('Item Saved')</script>"); Even the same message displayed.

Can you post the entire button click event here. And when do u get the Item Saved alert, b4 or after confirmation message?

Hi,

The button click event code is:

protected void imgSave_Click(object sender, ImageClickEventArgs e)
    {
        if (txtCountryid.Text != "")
        {
            int id = Convert.ToInt32(txtCountryid.Text.ToString());
            string name = txtCountryName.Text;

            DataSet ds = new DataSet();
            ds = country.countnameProc(9, 0, name);
            DataTable dt = ds.Tables[0];
            if (dt.Rows.Count != 0)
            {
                MsgBox1.alert("Alredy Exist");
                txtCountryid.Text = "";
                txtCountryName.Text = "";
            }
            else
            {
                country.countnameProc(1, id, name);
                ffilllstSearch();
                //Response.Write(@"<script language='javascript'>alert('Item Saved')</script>");
                MsgBox1.alert("ItemSaved");
                txtCountryid.Text = "";
                txtCountryName.Text = "";
            }
                        }

        else
        {
            MsgBox1.alert("Add New Item");
        }
    }

It works and 'Item saved' message displayed only after the Internet Explorer message displyed and click on 'No'.
Thanks in Advance.

This question has already been answered. Start a new discussion instead.