checkbox validation

Results 1 to 2 of 2

Thread: checkbox validation

  1. #1
    Join Date
    Dec 1969

    Default checkbox validation

    I have a datagrid. In the datagrid is a list of checkboxes for deleting rows. If the user checks one or more of the boxes, I need to ask the user "are you sure?" on the client. I used to do this with JavaScript in ASP all the time. I just don't understand how to work that in in .net. Any suggestions? Thanks.

  2. #2
    Join Date
    Dec 1969

    Default RE: checkbox validation

    Add your javascript to the HTML as before then in the ItemDataBound sub for the DataGrid add something like<BR>If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then<BR> Dim chkBx As checkbox = New checkbox()<BR> chkBx = CType(e.Item.Cells(0).Controls(0), CheckBox)<BR> chkBx.Attributes.Add("onclick", "jscript")<BR>end if<BR><BR>This will add an onclick event to the checkbox that will call your javascript client side. (Don&#039;t set the auto post back event to true for the checkbox as this will add an onclick aswell).<BR><BR>This should be more or less correct (but I have not run it).<BR>Hope it helps.<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts