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
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
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
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