Click here to Skip to main content
14,299,779 members
Rate this:
Please Sign up or sign in to 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.

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.
Rate this:
Please Sign up or sign in to vote.

Solution 1

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">
   
v2
Comments
Dalek Dave 22-Feb-11 9:30am
   
Edited for code block.
Rate this:
Please Sign up or sign in to vote.

Solution 3

You can also try this for confirmation of delete issue.

<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


<asp:button onclientclick="return confirm_delete ()" xmlns:asp="#unknown">
   
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.
Rate this:
Please Sign up or sign in to vote.

Solution 2

Hope javascript-alert-window-closed-76659[^] might help you.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100