Force postback with javascript? *Renewed!*
I would like my textboxes to post after they lose focus. I'm assuming the onblur event can be used with the boxes in code behind, but what's the syntax for forcing a postback?
Found it!
Code:
Dim js As String = "javascript:" & Page.GetPostBackEventReference(Me, "@@@@@buttonPostBack") & ";"
txtFirstName.Attributes.Add("onblur", js)
Haveing textboxes constantly post is very anoying. Is there a way to run a vb.net sub in a onblur event? Or can any of you convert my mess into js?
VB Code:
ibtSaveComp.Attributes.Remove("onClick")
If txtFirstName.Text <> Nothing And txtLastName.Text <> Nothing And txtGroupName.Text <> Nothing Then
If IO.File.Exists(AppSettings("CompDir") & txtGroupName.Text & "\" & txtLastName.Text & ", " & (txtFirstName.Text & " " & txtMI.Text).TrimEnd & ".xml") Then
Page.RegisterClientScriptBlock("DeleteComp", "<script language='javascript'>function DeleteComp(){ return confirm('Are you sure you wish to replace this item');}</script>")
Else
Page.RegisterClientScriptBlock("DeleteComp", "<script language='javascript'>function DeleteComp(){return true;}</script>")
End If
Else
Page.RegisterClientScriptBlock("DeleteComp", "<script language='javascript'>function DeleteComp(){return true;}</script>")
End If
ibtSaveComp.Attributes.Add("onClick", "return DeleteComp()")
End Sub
What I'm doing is checking if a file exists at post, so I know to raise a confirm box when the button is clicked.