?
Solved

How do I get this VB script in my HTML to work?

Posted on 2014-10-20
2
Medium Priority
?
163 Views
Last Modified: 2014-10-20
I'm unfamiliar with VB and scripting it inside of HTML (.aspx page) I have a segment that I'm trying to get working but am having trouble with one line.

        Protected Overrides Sub OnInit(e As EventArgs)
            InitializeComponent()
            MyBase.OnInit(e)
        End Sub

        Private Sub InitializeComponent()
            Me.ibSearch.Click += New System.Web.UI.ImageClickEventHandler(Me.ibSearch_Click)
            //IN THE LINE ABOVE, I'M BEING TOLD THAT I NEED TO USE 'RaiseEvent'? BUT I'M 
            //SURE THERE'S MORE TO IT AND SOMETHINGS THAT I'M MISSING BUT I'M TOO
           //UNFAMILIAR TO KNOW WHAT. HELP
        End Sub
        
        Sub ibSearch_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs)
            ' Get search terms
            Dim searchTerms As String = txtSearchTerms.Text

            ' Check search terms
            If searchTerms IsNot Nothing Then
                ' Set search output page
                Dim outUrl As String = Page.Request.Path

                ' Build query string
                Dim queryStr As String = (outUrl & "?usterms=" & searchTerms & "&ustype=") + ddlSearchType.SelectedValue

                ' Redirect to search output page
                Page.Response.Redirect(queryStr, True)
            End If
        End Sub

Open in new window


        Private Sub InitializeComponent()
            Me.ibSearch.Click += New System.Web.UI.ImageClickEventHandler(Me.ibSearch_Click)
            //IN THE LINE ABOVE, I'M BEING TOLD THAT I NEED TO USE 'RaiseEvent'? BUT I'M
            //SURE THERE'S MORE TO IT AND SOMETHINGS THAT I'M MISSING BUT I'M TOO
           //UNFAMILIAR TO KNOW WHAT. HELP
        End Sub
0
Comment
Question by:Michael Sterling
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 34

Accepted Solution

by:
it_saige earned 2000 total points
ID: 40392945
Try:
Private Sub InitializeComponent()
	AddHandler Me.lbSearch.Click, AddressOf Me.ibSearch_Click
End Sub

Open in new window

Or
Sub ibSearch_Click(sender As Object, e As System.Web.UI.ImageClickEventArgs) Handles Me.lbSearch.Click
	' Get search terms
	Dim searchTerms As String = txtSearchTerms.Text

	' Check search terms
	If searchTerms IsNot Nothing Then
		' Set search output page
		Dim outUrl As String = Page.Request.Path

		' Build query string
		Dim queryStr As String = (outUrl & "?usterms=" & searchTerms & "&ustype=") + ddlSearchType.SelectedValue

		' Redirect to search output page
		Page.Response.Redirect(queryStr, True)
	End If
End Sub

Open in new window


With the first code block you add an handler.  However, vb allows you to assign the handler directly to the method that the event raises.  So if you use the second code block, remove the code in the first code block.

-saige-
0
 
LVL 1

Author Closing Comment

by:Michael Sterling
ID: 40392967
That did it. Thank you.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question