Results 1 to 1 of 1

Thread: Force postback with javascript? *Renewed!*

  1. #1

    Thread Starter
    Code Monkey wild_bill's Avatar
    Join Date
    Mar 2005
    Location
    Montana
    Posts
    2,993

    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:
    1. ibtSaveComp.Attributes.Remove("onClick")
    2.         If txtFirstName.Text <> Nothing And txtLastName.Text <> Nothing And txtGroupName.Text <> Nothing Then
    3.             If IO.File.Exists(AppSettings("CompDir") & txtGroupName.Text & "\" & txtLastName.Text & ", " & (txtFirstName.Text & " " & txtMI.Text).TrimEnd & ".xml") Then
    4.                 Page.RegisterClientScriptBlock("DeleteComp", "<script language='javascript'>function DeleteComp(){ return confirm('Are you sure you wish to replace this item');}</script>")
    5.             Else
    6.                 Page.RegisterClientScriptBlock("DeleteComp", "<script language='javascript'>function DeleteComp(){return true;}</script>")
    7.             End If
    8.         Else
    9.             Page.RegisterClientScriptBlock("DeleteComp", "<script language='javascript'>function DeleteComp(){return true;}</script>")
    10.         End If
    11.         ibtSaveComp.Attributes.Add("onClick", "return DeleteComp()")
    12.     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.
    Last edited by wild_bill; Jun 29th, 2005 at 01:14 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width