Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp.net javascript message show get response and delete row

Posted on 2013-05-15
1
Medium Priority
?
508 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

Question has a verified solution.

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

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
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…

715 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