I
IntraRELY
I need to attach the following 2 little scripts to an ASP.NET Button. I am
having an issue with running both of the Attributes.Add. I can only get on
to work at once. I have also tried to put them both/either in the page_load,
but cannot get it to work.
TIA,
Steve Wofford
www.IntraRELY.com
SUEDO Code:
----------------------
User clicks btnPrint
Sc. 1
btnPrint.Attributes.Add("OnClick", "javascript:return confirm('Are you sure
you want to print these checks?');")
removed records from the datagrid and redraws it w/o the checks records.
Sc. 2
btnPrint.Attributes.Add("onclick", "window.open('printCheckClient.exe',
1);")
Local vb.net client queries the db for the records that where removed from
the above datagrid.
ACTUAL CODE:
-----------------------
' Sc. 1
btnPrint.Attributes.Add("OnClick", "javascript:return confirm('Are you sure
you want to print these checks?');")
Dim checkIdItem As DataGridItem
sqlChecks.Open()
For Each checkIdItem In dgChecks.Items
Dim dgCheckbox As CheckBox = CType(checkIdItem.Cells(0).Controls(1),
CheckBox)
If dgCheckbox.Checked Then
Dim selectedCheckId = dgChecks.DataKeys(checkIdItem.ItemIndex)
With cmdChecksPrintUpdate
..Parameters("@checkId").Value = selectedCheckId
..Parameters("@printed").Value = 2
End With
Try
Dim eNonQuery = cmdChecksPrintUpdate.ExecuteNonQuery
With cmdChecksCount
..Parameters("@printed").Value = globalPrinted
End With
dgChecks.VirtualItemCount = cmdChecksCount.ExecuteScalar()
Catch ex As SqlClient.SqlException
lblMessage.Text = "Unexplected error." + ex.Message
Finally
End Try
End If
Next
If dgChecks.CurrentPageIndex = 0 Then
dgChecks_fill(globalPrinted)
Else
If Math.Ceiling(dgChecks.VirtualItemCount / dgChecks.PageSize) <
dgChecks.PageCount Then
Dim currentPageIndex = dgChecks.CurrentPageIndex
Dim pageCount = dgChecks.PageCount
If currentPageIndex + 1 = pageCount Then
dgChecks.CurrentPageIndex = Math.Ceiling(dgChecks.VirtualItemCount /
dgChecks.PageSize) - 1
Dim topExclude = (dgChecks.CurrentPageIndex) * dgChecks.PageSize
dgChecks_fill(topExclude)
Else
Dim topExclude = (dgChecks.CurrentPageIndex) * dgChecks.PageSize
dgChecks_fill(topExclude)
End If
Else
Dim topExclude = (dgChecks.CurrentPageIndex) * dgChecks.PageSize
dgChecks_fill(topExclude)
End If
End If
' Sc. 2
btnPrint.Attributes.Add("onclick", "window.open('printCheckClient.exe',
1);")
End Sub
having an issue with running both of the Attributes.Add. I can only get on
to work at once. I have also tried to put them both/either in the page_load,
but cannot get it to work.
TIA,
Steve Wofford
www.IntraRELY.com
SUEDO Code:
----------------------
User clicks btnPrint
Sc. 1
btnPrint.Attributes.Add("OnClick", "javascript:return confirm('Are you sure
you want to print these checks?');")
removed records from the datagrid and redraws it w/o the checks records.
Sc. 2
btnPrint.Attributes.Add("onclick", "window.open('printCheckClient.exe',
1);")
Local vb.net client queries the db for the records that where removed from
the above datagrid.
ACTUAL CODE:
-----------------------
' Sc. 1
btnPrint.Attributes.Add("OnClick", "javascript:return confirm('Are you sure
you want to print these checks?');")
Dim checkIdItem As DataGridItem
sqlChecks.Open()
For Each checkIdItem In dgChecks.Items
Dim dgCheckbox As CheckBox = CType(checkIdItem.Cells(0).Controls(1),
CheckBox)
If dgCheckbox.Checked Then
Dim selectedCheckId = dgChecks.DataKeys(checkIdItem.ItemIndex)
With cmdChecksPrintUpdate
..Parameters("@checkId").Value = selectedCheckId
..Parameters("@printed").Value = 2
End With
Try
Dim eNonQuery = cmdChecksPrintUpdate.ExecuteNonQuery
With cmdChecksCount
..Parameters("@printed").Value = globalPrinted
End With
dgChecks.VirtualItemCount = cmdChecksCount.ExecuteScalar()
Catch ex As SqlClient.SqlException
lblMessage.Text = "Unexplected error." + ex.Message
Finally
End Try
End If
Next
If dgChecks.CurrentPageIndex = 0 Then
dgChecks_fill(globalPrinted)
Else
If Math.Ceiling(dgChecks.VirtualItemCount / dgChecks.PageSize) <
dgChecks.PageCount Then
Dim currentPageIndex = dgChecks.CurrentPageIndex
Dim pageCount = dgChecks.PageCount
If currentPageIndex + 1 = pageCount Then
dgChecks.CurrentPageIndex = Math.Ceiling(dgChecks.VirtualItemCount /
dgChecks.PageSize) - 1
Dim topExclude = (dgChecks.CurrentPageIndex) * dgChecks.PageSize
dgChecks_fill(topExclude)
Else
Dim topExclude = (dgChecks.CurrentPageIndex) * dgChecks.PageSize
dgChecks_fill(topExclude)
End If
Else
Dim topExclude = (dgChecks.CurrentPageIndex) * dgChecks.PageSize
dgChecks_fill(topExclude)
End If
End If
' Sc. 2
btnPrint.Attributes.Add("onclick", "window.open('printCheckClient.exe',
1);")
End Sub