Confirm messgae

Confirm messgae

23 Feb 2010 01:02:51
Hi All, i've a grid,it contain delete column.If user click delete.im checking some validation with database if that validation is true i want to populate confirm message to continue or not.how can i use?i tried.but all blogs saying we have to give control name.but here i cant give button name.becose this sub set of validation.anyone know how to use? thanks
Fresh   Boarder
Posts: 4
From 03-Jun-2009
You're Points: 76
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:51
Hi You need work like this way Say you have delete column like this way in gridview [b]HTML [/b] 1. DeleteWhen you are bind data to gridiview , you need set a client side script to your delete link button [b]C# Code[/b] 2. protected void CGgrdivewDemo_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lnkbtnDelete= (LinkButton)e.Row.FindControl("lnkbtnDelete"); lnkbtnDelete.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete this record " + DataBinder.Eval(e.Row.DataItem, "PrimaryKeyColumn") + "')"); } } When you are press link delete link button it will delete based on your response.but we need do one more step to delete from the Database that record. To this we can use the Row Command event in gridview. 3. protected void CGgrdivewDemo_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { int PrimaryKeyColumnValue = Convert.ToInt32(e.CommandArgument); // then call the delete method and pass the primakrycolulmvalue to delete that record in db } } That's all.let you try it, if you found any issue let me know. Thank you
RRaveen
Gold  Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:51
I dont need to validate when clicking time.i want to validate after click.
Push
Fresh  Boarder
Posts: 4
From 03-Jun-2009
You're Points: 76
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:51
Hi Yes validation not happening, when you are click in link button, just client message will come to continue after that it will validate data and etc. thank you
RRaveen
Gold  Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:51
you r calling on click event .i dont want tht lnkbtnDelete.Attributes.Add("onclick", "javascript:return " + "confirm('Are you sure you want to delete this record " + DataBinder.Eval(e.Row.DataItem, "PrimaryKeyColumn") + "')"); here u've added attributes on link button click event.this mean before proceesing u r confiming.if no it wont fire the delete function.but i want to fire the delete button.while deleting want to ask some confirmation but not related with whether delete or not.
Push
Fresh  Boarder
Posts: 4
From 03-Jun-2009
You're Points: 76
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:52
Hi Then its can't in client side validation, you need use the client side and after perform confirmation from the server. and even if you are press delete button, first client side script will execute, then server side. According your words now you need server side check something, based on values to need ask confirmation to users. Even you can't do like windows form validation in asp.net, because client side always first. YOu need server side action other than client side,Just try with this message box [url]http://www.dnzone.com/go?813[/url] thank you
RRaveen
Gold  Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:52
any way thanks. i did like this.its work System.Windows.Forms.DialogResult dr = System.Windows.Forms.MessageBox.Show("Are you sure to continue this?", "validation", System.Windows.Forms.MessageBoxButtons.YesNo, System.Windows.Forms.MessageBoxIcon.Exclamation, System.Windows.Forms.MessageBoxDefaultButton.Button1, System.Windows.Forms.MessageBoxOptions.DefaultDesktopOnly); if (dr.ToString().ToUpper() == "YES") { ///do some thing } else { //do something }
Push
Fresh  Boarder
Posts: 4
From 03-Jun-2009
You're Points: 76
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:52
Hi Great, but just take look at this [url]http://forums.asp.net/p/1454337/3326495.aspx[/url] thank you
RRaveen
Gold  Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:52
Hi I have noticed , windows form message box work only local , not server. Please try to change your solution. [url]http://www.codeproject.com/Messages/2858093/Message-Box-using-System-Windows-Forms-MessageBox-is-return-error-on-the-server-modified.aspx[/url] thank you
RRaveen
Gold  Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:52
any one got answer for my quest?i found but its not working inside update pannel.any idea?
Push
Fresh  Boarder
Posts: 4
From 03-Jun-2009
You're Points: 76
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:52
i got the link but its not working inside update panal. http://www.codeproject.com/KB/webforms/NingLiangSimpleControl.aspx can anyone help?
Push
Fresh  Boarder
Posts: 4
From 03-Jun-2009
You're Points: 76
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:52
Hi See that message Box not working update panel. already one user have commented in that end of the article May be you need update your AJAX version.i think it's may be help thank you
RRaveen
Gold  Boarder
Posts: 156
From 03-Jun-2009
You're Points: 1106
Bookmark
Re:Confirm messgae23 Feb 2010 01:02:52
yes.thts y asked any idea?
Push
Fresh  Boarder
Posts: 4
From 03-Jun-2009
You're Points: 76
Bookmark
^ Scroll to Top