Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Button Click event

Status
Not open for further replies.

mych

Programmer
May 20, 2004
248
GB
I have a text box and button on a page. I want to set the TargetURL at the Click event so that I can pass a Querystring.

My code is....

Code:
Protected Sub ButFind_Click(By Val sender As Object, ByVal e As System.EventArgs)

    Dim clickedButton AS Button = sender
    
    clickedButton.PostBackUrl - "FindCandidate.aspx=?CID" & txFindCandidate.text

End Sub

My problem is that the code says txFindCandidate is not defined. Where have I gone wrong?

Thanks

I've not failed! Just found 100 ways that don't work...yet!
 
OK fixed....

First I tried....
Code:
Protected Sub ButFind_Click(By Val sender As Object, ByVal e As System.EventArgs)

    Dim clickedButton As Button = sender
    Dim CandNo As String = Me.txFindCandidate.text
    
    clickedButton.PostBackUrl = "FindCandidate.aspx=?CID" & CandNo

End Sub
This worked but required the button to be pressed twice.

I then changed the code to....
Code:
Protected Sub ButFind_Click(By Val sender As Object, ByVal e As System.EventArgs)

    Dim CandNo As String = Me.txFindCandidate.text
    
    Request.Redirect("FindCandidate.aspx=?CID" & CandNo)

End Sub
Works great even though Me.txFindCandidate has a blue wavy line and it says 'txFindCandidate' is not a member of '_Default'

Mych

I've not failed! Just found 100 ways that don't work...yet!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top