954,577 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Image Button Click Error

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.

ssreevidya.m
Junior Poster in Training
51 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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.

Aneesh_Argent
Junior Poster
104 posts since Dec 2008
Reputation Points: 16
Solved Threads: 18
 

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.

ssreevidya.m
Junior Poster in Training
51 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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.

Aneesh_Argent
Junior Poster
104 posts since Dec 2008
Reputation Points: 16
Solved Threads: 18
 

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.

ssreevidya.m
Junior Poster in Training
51 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

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

Aneesh_Argent
Junior Poster
104 posts since Dec 2008
Reputation Points: 16
Solved Threads: 18
 

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.

ssreevidya.m
Junior Poster in Training
51 posts since Jan 2009
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You