Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net javascript message show get response and delete row

Posted on 2013-05-15
1
Medium Priority
?
513 Views
Last Modified: 2013-05-28
I have an asp.net web app.

in a gridview i list some records and there is a delete asp button in each row.

when i click delete button on the page.

i pop up javascript message in GridView1_RowDataBound

since this is a click event i catch it with below line.

Button x = e.Row.FindControl("DeleteButton") as Button;
            x.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete:-" + x.CommandArgument.ToString() + "');");


But after that in the Row_Command i make a check on the patient and if operations exist on him/her (if i==true)

i want to display another pop up saying that operations exist do you still want to delete everything related with this person and according to the response i will delete or not.

What i could not achieve is ;

Since the second popup is not coming from button click or smthg i could not show the pop up,and get the user response, if user said OK then i should delete in the code behind if Cancel then do nothing.

As you can see my codes below can you help a little with the code what i should put to this code to make this work.. by the way i use MasterPage so ContentPlaceholder exists.
********************************
DESIGN
   <asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_RowCommand" OnRowDataBound="GridView1_RowDataBound" OnRowDeleting="GridView1_RowDeleting">
    <Columns>

        <asp:TemplateField HeaderText="Silinecek">
            <ItemTemplate>
                <asp:Button ID="DeleteButton" runat="server" CommandName="Delete"  CommandArgument=<%#Eval("AD")%> Text="Delete"  />
            </ItemTemplate> 
        </asp:TemplateField>

    </Columns>
    </asp:GridView>

Open in new window

**************************************************
CODEBEHIND
  protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {

           Button x = e.Row.FindControl("DeleteButton") as Button;
            x.Attributes.Add("onclick", "javascript:return confirm('Are you sure you want to delete:-" + x.CommandArgument.ToString() + "');");
                  }
    }


protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "Delete")
        {
           string patient= e.CommandArgument.ToString();
           bool i = checkpatientexists(patient);

            if (i == true)'operations exist
            {
                ContentPlaceHolder cph = (ContentPlaceHolder)this.Master.FindControl("ContentPlaceHolder1");
                Button y = (Button)cph.FindControl("y");

                y.Attributes.Add("onclick", "javascript:return confirm('Do you again delete?:-');");

System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=JavaScript> if(confirm(Patient has operations==>>" + e.CommandArgument.ToString() + "')==true){};</SCRIPT>");
               
            }
        }
    }

Open in new window

0
Comment
Question by:nicedone
1 Comment
 
LVL 29

Accepted Solution

by:
Kumaraswamy R earned 2000 total points
ID: 39186539
Hi

change java scrpit reg

ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "<script type='text/javascript'>" + "alert('Record deleted successfully!!!');</" + "script>");

http://www.dotnetspider.com/forum/293684-Show-alert-or-confirm-message-from-serverside-asp.net.aspx
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

886 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question