Click here to Skip to main content
15,907,001 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hi,

I have created a web page that contains 4 fields and a filter button.
Based on the values entered in the textboxes a report will be generated.
The report is a grid view.This a report that contains issues.

When I click on any issue in the report it will show you all the details of that issue it has a close button.
When I click on a close button it will close the issue,(means it will delete the issue from the report).

And now the problem is I want to put an alert on a close button so that it will show an alert when the issue is closed.

I have tried the following way.

1)Response.Write("<script>alert('Issue has been closed')</script>");

When I tried this it is showing me the alert message but I cannot see the screen backside.
It is showing me a white blank page when the alert pops out.

I have tried the following javascript funtion,but no use.

XML
public static class Alert
{
/// <summary>
/// Shows a client-side JavaScript alert in the browser.
/// </summary>
/// <param name="message">The message to appear in the alert.</param>
public static void Show(string message)
{
// Cleans the message to allow single quotation marks
string cleanMessage = message.Replace("'", "\\'");
string script = "<script type=\"text/javascript\">alert('" + cleanMessage + "');</script>";
// Gets the executing web page
Page page = HttpContext.Current.CurrentHandler as Page;
// Checks if the handler is a Page and that the script isn't allready on the Page
if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert"))
{
page.ClientScript.RegisterClientScriptBlock(typeof(Alert), "alert", script);
}
}
}



Can any one please help me regarding this .
Its very urgent.

Thanks in advance
Posted
Updated 22-Feb-11 3:29am
v3
Comments
Dalek Dave 22-Feb-11 9:29am    
Edited for Grammar and Readability.

attach a script to your aspx file with an alert function like this

function ShowMessage(message)
{
   alert(message);
}

call the function on the clientclick event of the close button

<asp:button onclientclick="ShowMessage('Issue will be deleted')" xmlns:asp="#unknown">
 
Share this answer
 
v2
Comments
Dalek Dave 22-Feb-11 9:30am    
Edited for code block.
You can also try this for confirmation of delete issue.

XML
<script language="JavaScript">
      <!--
            function confirm_delete()
            {
                  input_box=confirm("Are you sure you want to delete this issue?");
                  if (input_box==true)
                 {
                     // Output when OK is clicked
                      return true;
                  }
                  else
                  {
                       // Output when Cancel is clicked
                      return false;
                  }

            }
      -->
</script>


And then call the function on the clientclick event of the close button


C++
<asp:button onclientclick="return confirm_delete ()" xmlns:asp="#unknown">
 
Share this answer
 
Comments
Dalek Dave 22-Feb-11 9:30am    
Good Answer.
neha427 22-Feb-11 15:36pm    
Hi Vivek,
Thank you.
Your piece of code gives the confirmation first and then issue is closed.
But the problem is I need the confirmation after the issue has been closed.I should get a message that "Issue closed successfully"

Thanks
Vivek.Net 23-Feb-11 4:11am    
Hi Neha,
For that you need to use ajax and it will sovle your problem without any flikring on web page. Steps will be Like
1)create a aspx page
2) get errorId from queryString.
3) write code to close that issue on page load and write responce on same page.
4) Call that issueClose page using ajax and read responce then show msg accordingly.

One more trick is there. i'll prepare code for that and send you soon.
Hope javascript-alert-window-closed-76659[^] might help you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900