Showing posts with label confirm. Show all posts
Showing posts with label confirm. Show all posts

Thursday, March 29, 2012

Please anyone has confirm message box with yes No buttons in it for asp.net page

Please i am looking for a javascript code to use with confirm message box with two buttons Yes and NO in it.

Thank you very much.How about 'OK' and 'Cancel'?

if that's ok - check out :
http://aspnet101.com/aspnet101/aspnet/codesample.aspx?code=confirm
Hello David,
Thank's a lot, I will try the messagebox code.

Friday, March 16, 2012

please help me to clear this error

hi, i am working in c# asp.net.

my cs:

public void confirm(Object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.Item.ItemType ==ListItemType.Item//e.Item.ItemType ==ListItemType.AlternatingItem)
{
LinkButton lb=(LinkButton)e.Item.Cells[0].FindControl("btndelete");
lb.Attributes["onclick"]="return(confirm('Confermi?'))";
}

}
i am using this coding to show confirm button while clicking the delete button.
this is my aspx:
<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 160px; POSITION: absolute; TOP: 56px"
runat="server" OnDeleteCommand="cmddelete" DataKeyField="age" OnUpdateCommand="cmdupdate"
OnEditCommand="cmdedit" OnItemDataBound ="confirm" OnCancelCommand="cmdcancel" AutoGenerateColumns="False" OnItemCommand="insert"
ShowFooter="True" HeaderStyle-BackColor="#660033" HeaderStyle-ForeColor="white" BackColor="#660033"
ForeColor="#ffffff">

i did for edit,insert,delete allthe things correctly and works well, then i added this confirm delete, for this confirm i am getting the following error:

Compiler Error Message: CS0123: Method 'sqlserver.WebForm4.confirm(object, System.Web.UI.WebControls.DataGridCommandEventArgs)' does not match delegate 'void System.Web.UI.WebControls.DataGridItemEventHandler(object, System.Web.UI.WebControls.DataGridItemEventArgs)'

so please help me to solve this error,pleaseeeeeeeeeeeeeeeeTry Changing
public void confirm(Object source,System.Web.UI.WebControls.DataGridCommandEventArgs e)
To
public void confirm(Object source,System.Web.UI.WebControls.DataGridItemEventArgs e)
hi ferris, thanks for reply and i did modification as what u said, i am getting error in this,

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

public void confirm(Object source,System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType ==ListItemType.Item||e.Item.ItemType ==ListItemType.AlternatingItem)
{
//LinkButton btn=((LinkButton)e.Item.FindControl("delete"));
//btn.Attributes.Add("onclick","return confirm('Are you sure you want to delete this company?');");
LinkButton lb=(LinkButton)e.Item.Cells[0].FindControl("btndelete");
lb.Attributes["onclick"]="return(confirm('Confermi?'))";
//b.Attributes.Add("onclick","return confirm('Are you sure you want to delete this company?');");
}
}

please help me to rectify this error.
Hi,

Try changing

LinkButton lb=(LinkButton)e.Item.Cells[0].FindControl("btndelete");
lb.Attributes["onclick"]="return(confirm('Confermi?'))";

To

LinkButton lb = (LinkButton)e.Item.FindControl("btnDelete");
lb.Attributes.Add("onclick", "return(confirm('Confermi?'));

hth