Click here to Skip to main content
15,888,579 members
Home / Discussions / ASP.NET
   

ASP.NET

 
QuestionHow to open excel in asp.net??? Pin
JC.KaNNaN10-Feb-10 21:07
JC.KaNNaN10-Feb-10 21:07 
AnswerRe: How to open excel in asp.net??? Pin
saini arun10-Feb-10 21:49
saini arun10-Feb-10 21:49 
QuestionI want to add, edit and delete data from table using gridview in Asp.net? Pin
mdrizwan_110-Feb-10 20:03
mdrizwan_110-Feb-10 20:03 
AnswerRe: I want to add, edit and delete data from table using gridview in Asp.net? Pin
i gr810-Feb-10 20:26
i gr810-Feb-10 20:26 
GeneralRe: I want to add, edit and delete data from table using gridview in Asp.net? Pin
mdrizwan_111-Feb-10 4:05
mdrizwan_111-Feb-10 4:05 
GeneralI need Help with FTP browser ! Pin
mgexpression10-Feb-10 20:01
mgexpression10-Feb-10 20:01 
Questionhow to use menu control using database... Pin
hi_everybody10-Feb-10 19:42
hi_everybody10-Feb-10 19:42 
QuestionModalPopupExtender confirmation not working in <asp:CommandFiel in grid view Pin
Vishnu Narayan Mishra10-Feb-10 18:59
Vishnu Narayan Mishra10-Feb-10 18:59 
Hi to all forum members.

I am stuck in implementing ModalPopupExtender in <asp:CommandField in grid view.
Although below code is working fine in <asp:template field in grid view.
<asp:TemplateField HeaderText="Delete" HeaderStyle-CssClass="tableheading" HeaderStyle-Width="70px">
<ItemTemplate>
<center>
<asp:ImageButton ID="imgDelete" runat="server" OnClientClick="showConfirm(this); return false;"
ImageUrl="~/Images/delete.png" OnClick="imgBtnDelete_Click" /></center>
</ItemTemplate>
</asp:TemplateField>


following is my code which I am trying to implement in <asp:CommandFiel in grid view.
.aspx code


Grid view code
<asp:CommandField HeaderText="Edit/Delete" ItemStyle-HorizontalAlign="Center" CausesValidation="false"
ShowCancelButton="true" ShowEditButton="True" ShowDeleteButton="true" />

modal popup code
<ajaxToolkit:ModalPopupExtender ID="md1" runat="server" BackgroundCssClass="modalBackground"
BehaviorID="mdlPopup" CancelControlID="btnNo" OkControlID="btnOk" OnCancelScript="cancelClick();"
OnOkScript="okClick();" PopupControlID="Confiramtiondiv" TargetControlID="Confiramtiondiv">
</ajaxToolkit:ModalPopupExtender>
<div id="Confiramtiondiv" runat="server" align="center" style="display: none">
<table id="Table3" cellpadding="1" cellspacing="1" border="0" bordercolor="blue"
runat="server" align="center">
<tr>
<td colspan="4" align="center">
<asp:Label ID="lblConfirmmsg" runat="server" Text="Are you sure you want to delete this Trip ?"
CssClass="lblConfirmmsg"></asp:Label>
</td>
</tr>
<tr>
<td width="20%">
</td>
<td width="30%">
<asp:Button ID="btnOk" runat="server" Text="Yes" CausesValidation="false" Width="50px" />
</td>
<td width="30%">
<asp:Button ID="btnNo" runat="server" CausesValidation="false" Text="No" Width="50px" />
</td>
<td width="20%">
</td>
</tr>
</table>
</div>


.cs code
protected void grdTrips_RowDataBound(object sender, GridViewRowEventArgs e)
{


if (e.Row.RowState != DataControlRowState.Edit) // check for RowState
{
if (e.Row.RowType == DataControlRowType.DataRow) //check for RowType
{
string id = e.Row.Cells[0].Text; // Get the id to be deleted
LinkButton lb = (LinkButton)e.Row.Cells[8].Controls[2]; //cast the ShowDeleteButton link to linkbutton
if (lb != null && lb.Text == "Delete")
{

lb.Attributes.Add("onclick", "showConfirm(this); return false;"); //implementing Ajax modal popup extender

}
}
}


Java Script Function

// keeps track of the delete button for the row
// that is going to be removed
var _source;
// keep track of the popup Confiramtiondiv
var _popup;

function showConfirm(source){
this._source = source;
this._popup = $find('mdlPopup');

// find the confirm ModalPopup and show it
this._popup.show();
}

function okClick(){
// find the confirm ModalPopup and hide it
this._popup.hide();
// use the cached button as the postback source
__doPostBack(this._source.name, '');
}

function cancelClick(){
// find the confirm ModalPopup and hide it
this._popup.hide();
// clear the event source
this._source = null;
this._popup = null;
}
This code opens modal popup but its does not goes to RowDeleting Event of gridview
.
When I changed this code
lb.Attributes.Add("onclick", "showConfirm(this); return false;");
to
lb.Attributes.Add("onclick", "showConfirm(this);");

it open the modal popup but then directly goes to to grid view RowDeleting Event of gridview with out asking confirmation from the users.
I again told this code is working fine in <asp:templatefield.


Welcome for your valuable suggestions
Vishnu Narayan Mishra
Software Engineer

QuestionHow to refresh Parent particular griview? Pin
JC.KaNNaN10-Feb-10 18:53
JC.KaNNaN10-Feb-10 18:53 
AnswerRe: How to refresh Parent particular griview? Pin
Gaurav Dudeja India10-Feb-10 18:56
Gaurav Dudeja India10-Feb-10 18:56 
GeneralRe: How to refresh Parent particular griview? Pin
JC.KaNNaN10-Feb-10 19:50
JC.KaNNaN10-Feb-10 19:50 
QuestionHow to assign the total value of a column to the footer? Pin
TeiUKei10-Feb-10 18:34
TeiUKei10-Feb-10 18:34 
AnswerRe: How to assign the total value of a column to the footer? Pin
Gaurav Dudeja India10-Feb-10 18:54
Gaurav Dudeja India10-Feb-10 18:54 
NewsGoogle API - graph Pin
Member 395625710-Feb-10 18:17
Member 395625710-Feb-10 18:17 
GeneralRe: Google API - graph Pin
nainakarri10-Feb-10 18:58
nainakarri10-Feb-10 18:58 
GeneralRe: Google API - graph Pin
Member 395625710-Feb-10 19:36
Member 395625710-Feb-10 19:36 
GeneralRe: Google API - graph Pin
Anurag Gandhi10-Feb-10 20:42
professionalAnurag Gandhi10-Feb-10 20:42 
QuestionFind How many Enter Key Press Pin
sjs4u10-Feb-10 17:55
sjs4u10-Feb-10 17:55 
AnswerRe: Find How many Enter Key Press Pin
Anurag Gandhi10-Feb-10 18:19
professionalAnurag Gandhi10-Feb-10 18:19 
Questionon keypress enter to submit login details IE is working but in firefox not working Pin
Nath10-Feb-10 15:40
Nath10-Feb-10 15:40 
QuestionCalling webservice Pin
Ramkithepower10-Feb-10 15:33
Ramkithepower10-Feb-10 15:33 
AnswerRe: Calling webservice Pin
Pranay Rana10-Feb-10 18:18
professionalPranay Rana10-Feb-10 18:18 
AnswerRe: Calling webservice Pin
sashidhar10-Feb-10 18:24
sashidhar10-Feb-10 18:24 
GeneralRe: Calling webservice Pin
Ramkithepower11-Feb-10 6:03
Ramkithepower11-Feb-10 6:03 
GeneralRe: Calling webservice Pin
sashidhar11-Feb-10 17:43
sashidhar11-Feb-10 17:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.