1.11M Members

getting true or false to c# back

 
0
 

Hi all so i have this lauching the javascript to the page:

Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Alert", "confirm('Are you  Sure You Want to Delete User??')", true);

But now i remebered that i need an answer on the codebehinf(C#).
So this way i can do the rest of the code, but im stuck with that, does anybody knows how to do that??

Thanks and Regards

 
1
 

A different approach may be more helpful.. For example....
Add an asp:Hidden field in your form, to store the "user is sure" value. Set its default value to false.

Then instead of using your code behind, add your javascript function in the .ASPX file directly.

Modify the function so that if the user clicks on "yes", you update the hidden input element's value to "yes" via javascript.

when the form is submitted, use your btnSubmit_Click() function to check the asp:Hidden value: if that value is true, you know the user has already confirmed the "are you sure" dialog.

 
0
 

thanks,

But the problem im using a damn radgrid from telerik and using the delete field i have to start everything first fro mteh code behind.

 
0
 

i wish it would be that easy,
but i cant use it because of the radgrid.

 
0
 

Try this:

private void RadGrid_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        GridDataItem dataItem = e.Item as GridDataItem;
        string contactName = dataItem["SomeField"].Text;

        LinkButton button = dataItem["ColumnName"].Controls[0] as LinkButton;
        button.Attributes["onclick"] = "return confirm('Are you  Sure You Want to Delete User??')";
    }
}
You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: